08:10:58.779 ServerScriptService.TimerScript:17: attempt to concatenate Instance with string - Server - TimerScript:17? - roblox

Im trying to make it so that it prints out the topplayer's name but it output prints the error on the title.
Heres the code:
local highest = 0
local mostvote = 0
while true do
wait(10)
local TopPlayer
local TopCash = 0
for i, plr in ipairs(game:GetService("Players"):GetChildren()) do
local kills = plr.leaderstats.Kills.Value
if kills >= TopCash then
TopPlayer = plr
TopCash = kills
end
end
print(TopPlayer.." Got the most kills so "..TopPlayer.Team.." wins!")
for i, plr in ipairs(game:GetService("Players"):GetChildren()) do
local kills = plr.leaderstats.Kills.Value
kills.Value = 0
end
end

print(TopPlayer.." Got the most kills so "..TopPlayer.Team.." wins!")
The error tells you what's happening : you've got an Instance of something and you're trying to add a string to it, and it doesn't know what to do with it.
TopPlayer is a Player instance, and you probably want to print out their name. So instead of using the Player instance directly, you should probably use their Name or their DisplayName in the message. Similarly, TopPlayer.Team is a Team instance, and you should probably print its Name as well.
print(TopPlayer.Name .." got the most kills so " .. TopPlayer.Team.Name .. " wins!")

Related

How to set initial player health to a custom value in Roblox Studio?

My goal is to have an initial/max custom player health for my Roblox place in Roblox Studio.
To do this I have created a script in StarterPlayer/StarterPlayerScript with the following content:
local DEFAULT_HEALTH = 10
game.Players.PlayerAdded:connect(function(player)
player.character.Humanoid.MaxHealth = DEFAULT_HEALTH
player.character.Humanoid.Health = DEFAULT_HEALTH
end)
I have also tried with:
local DEFAULT_HEALTH = 10
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.MaxHealth = DEFAULT_HEALTH
Humanoid.Health = DEFAULT_HEALTH
in both cases when I playtest it (TEST->PLAY) it seems the default health=100 is used instead of health=10
Is it possible to fix the issue outlined?
The PlayerAdded event fires as soon as the player joins the server, but their character model doesn't load into the world immediately. So you need to wait for the player's character model to spawb. Luckily, you can use the CharacterAdded event to know when that happens.
So using a Script in the Workspace or ServerScriptService, try this :
local DEFAULT_HEALTH = 10
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.MaxHealth = DEFAULT_HEALTH
character.Humanoid.Health = DEFAULT_HEALTH
end)
end)

Save job output from SDSF into a PDS and using ISPF functions in REXX

We periodically runs jobs and we need to save the output into a PDS and then parse the output to extract parts of it to save into another member. It needs to be done by issuing a REXX command using the percent sign and the REXX member name as an SDSF command line. I've attempted to code a REXX to do this, but it is getting an error when trying to invoke an ISPF service, saying the ISPF environment has not been established. But, this is SDSF running under ISPF.
My code has this in it (copied from several sources and modified):
parse arg PSDSFPARMS "(" PUSERPARMS
parse var PSDSFPARMS PCURRPNL PPRIMPNL PROWTOKEN PPRIMCMD .
PRIMCMD=x2c(PPRIMCMD)
RC = isfquery()
if RC <> 0 then
do
Say "** SDSF environment does not exist, exec ending."
exit 20
end
RC = isfcalls("ON")
Address SDSF "ISFGET" PPRIMPNL "TOKEN('"PROWTOKEN"')" ,
" (" VERBOSE ")"
LRC = RC
if LRC > 0 then
call msgrtn "ISFGET"
if LRC <> 0 then
Exit 20
JOBNAME = value(JNAME.1)
JOBNBR = value(JOBID.1)
SMPDSN = "SMPE.*.OUTPUT.LISTINGS"
LISTC. = ''
SMPODSNS. = ''
SMPODSNS.0 = 0
$ = outtrap('LISTC.')
MSGVAL = msg('ON')
address TSO "LISTC LVL('"SMPDSN"') ALL"
MSGVAL = msg(MSGVAL)
$ = outtrap('OFF')
do LISTCi = 1 to LISTC.0
if word(LISTC.LISTCi,1) = 'NONVSAM' then
do
parse var LISTC.LISTCi . . DSN
SMPODSNS.0 = SMPODSNS.0 + 1
i = SMPODSNS.0
SMPODSNS.i = DSN
end
IX = pos('ENTRY',LISTC.LISTCi)
if IX <> 0 then
do
IX = pos('NOT FOUND',LISTC.LISTCi,IX + 8)
if IX <> 0 then
do
address ISPEXEC "SETMSG MSG(IPLL403E)"
EXITRC = 16
leave
end
end
end
LISTC. = ''
if EXITRC = 16 then
exit 0
address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
I execute this code by typing %SMPSAVE next to the spool output line on the "H" SDSF panel and it runs fine until it gets to this point in the REXX:
114 *-* address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
>>> "TBCREATE SMPDSNS NOWRITE NAMES(TSEL TSMPDSN)"
ISPS118S SERVICE NOT INVOKED. A VALID ISPF ENVIRONMENT DOES NOT EXIST.
+++ RC(20) +++
Does anyone know why it says I don't have a valid ISPF environment and how I can get around this?
I've done quite a bit in the past with REXX, including writing REXX code to handle line commands, but this is the first time I've tried to use ISPEXEC commands within this code.
Thank you,
Alan

WSAEWOULDBLOCK 10035

I'm trying to make client-server connection, I don't know much about sockets etc. so I used github example for luajitsocket and im getting error "A non-blocking socket operation could not be completed immediately."
So I dont even know how can I fix that, that's why Im asking here
My code:
local port = 8080
local address = socket.find_first_address("*", port)
do -- server
local server = assert(socket.create("inet", "dgram", "udp"))
assert(server:set_blocking(false))
assert(server:bind(address))
print("hosting at ", address:get_ip(), address:get_port())
function update_server()
local data, addr = server:receive_from()
if data then
print(data)
assert(server:send_to(addr, "hello from server " .. os.clock()))
elseif addr ~= "timeout" then
error(addr)-- here
end
end
end
do -- client
local client = assert(socket.create("inet", "dgram", "udp"))
assert(client:set_blocking(false))
local next_send = 0
function update_client()
if next_send < os.clock() then
assert(client:send_to(address, "hello from client " .. os.clock()))
next_send = os.clock() + math.random() + 0.5
end
local data, addr = client:receive_from(address)
if data then
print(data, addr:get_ip(), addr:get_port())
elseif addr ~= "timeout" then
error(addr)
end
end
end
while true do
update_server()
update_client()
end
taken from: https://github.com/CapsAdmin/luajitsocket/blob/master/examples/udp_client_server.lua
I was looking about this error on google but can't find any working solution. Thanks in advance!
After set_blocking(false) that return code should not be considered abnormal.
You're probably getting it from receive_from(), which you should not be calling constantly, you should do it when select() or poll() tells you the socket has data waiting.

How do I make a working team changer GUI in roblox?

In 2018 Roblox switched coding platforms I believe, most scripts have survived, however I have failed to find a working team changer for myself this year that changes your team when clicked depending if you are in certian groups or not. My scripter says that it works in studio, but an error pops up in game that says "
TeamColor is not a valid member of PlayerGui
Stack Begin
Script 'Players.Benyal.PlayerGui.Starter GUI.TeamGui.Frame.Research and Development.LocalScript', Line 8
Stack End"
My scipter tried many different ways but it just wont work! Any seggustions?
This solution uses two scripts (one LocalScript and one Script), follow the steps below to make a team changing GUI!
local teams = game:GetService("Teams")
local settings = {
["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
["TitleText"] = "Team Changer", --title text in the gui
["TitleFont"] = "ArialBold", --font of title
}
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
local plr = game.Players.LocalPlayer
local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
local frame = Instance.new("Frame",teamGUI)
frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
local title = Instance.new("TextLabel",frame)
title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
local closebutton = Instance.new("TextButton",title)
closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
local list = Instance.new("ScrollingFrame",frame)
list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
local UILayout = Instance.new("UIListLayout",list)
local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
for i,v in pairs(getTeams) do
print("[Team " .. i .. " found]: " .. v:GetFullName())
local teamButton = Instance.new("TextButton",list)
teamButton.BackgroundColor3 = v.TeamColor.Color
teamButton.Size = UDim2.new(1,0,0,40)
teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
teamButton.MouseButton1Down:connect(function()
print("You changed teams. You are now in: " .. v.Name)
serverTeamHandler:InvokeServer(v)
end)
end
closebutton.MouseButton1Click:connect(function()
frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
local returnButton = Instance.new("TextButton",teamGUI)
returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
returnButton.MouseButton1Down:connect(function()
returnButton:Destroy()
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
end)
end)
Step 1 Insert a LocalScript into StarterGui
Step 2 Copy the stuff above and paste it into this LocalScript
Step 3 Insert a Script into either Workspace or ServerScriptService (your choice)
Step 4 Copy the stuff below and paste it into the Script
local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
teamChanger.Name = "teamChanger"
local function changeTeam(client,team)
print(client.Name .. "changed teams: now in" .. team.Name)
client.Team = team
end
teamChanger.OnServerInvoke = changeTeam
If you followed these steps correctly, you should now have a working team changing GUI in your game! It works as long as you have already inserted Teams in your game. The first few lines in the LocalScript can also be customized as well!

Open or close cd-drive using cmd

Whether there is any way to close and open cd-drive using cmd?
I can open it like this:
powershell (New-Object -com "WMPlayer.OCX.7").cdromcollection.item(0).eject()
But idk how to close it
(Of course I can push it in, but i mean how i can close it with cmd)
Found on Google with keywords :
powershell close cd rom drive
http://www.powershellmagazine.com/2013/11/12/pstip-ejecting-and-closing-cdrom-drive-the-powershell-way/
do
Dim ts
Dim strDriveLetter
Dim intDriveLetter
Dim fs 'As Scripting.FileSystemObject
Const CDROM = 4
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
strDriveLetter = ""
For intDriveLetter = Asc("A") To Asc("Z")
Err.Clear
If fs.GetDrive(Chr(intDriveLetter)).DriveType = CDROM Then
If Err.Number = 0 Then
strDriveLetter = Chr(intDriveLetter)
Exit For
End If
End If
Next
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null
For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null
set owmp = nothing
set colCDROMs = nothing
loop
save as .vbs
you might have to disable antivirus