Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Bad Argument #2(string expected, got Object) Admin Gui. Help???

Asked by 4 years ago
Edited 4 years ago

So I have a problem right now because whenever I try to use certain buttons in my gui, it will have an error printed out in the Developer Consoles saying: ServerScriptService.IHelpSadLocalScripts:10: bad argument #2 (string expected, got Object) and then it happens at line 10.

Also, there is the same exact error but on line 5, line 20, and line 26. This is my code:

game.ReplicatedStorage.moneyevent.OnServerEvent:Connect(function(player,asd,amount)
    game.ServerStorage.MoneyStorage[asd].Value = amount
end)
game.ReplicatedStorage.tempgui.OnServerEvent:Connect(function(player,asd)
    game.Players[asd].admingui.Contents.Visible = true
    game.Players[asd].admingui.Border1.Visible = true
    game.Players[asd].admingui.TempClose.Visible = true
end)
game.ReplicatedStorage.giveitem.OnServerEvent:Connect(function(player,asd,itemid,amount)
    game.ServerStorage.AwardItem:Invoke(game.Players[asd],itemid,amount)
end)
game.ReplicatedStorage.clearcrate.OnServerEvent:Connect(function(player,cratetype)
        for i,v in pairs(workspace:GetChildren()) do
            if v.Name == cratetype then
                v:Destroy()
            end
        end
    end)
game.ReplicatedStorage.ucevent.OnServerEvent:Connect(function(player,asd,amount)
        game.Players[asd].Crystals.Value = amount
    end)
game.ReplicatedStorage.crateevent.OnServerEvent:Connect(function(player,asd,cratetype,amount)
    game.ServerStorage[cratetype]:Clone().Parent = workspace workspace[cratetype].Position = workspace[asd].HumanoidRootPart.Position workspace[cratetype].Position = workspace[cratetype].Position + Vector3.new(20,0,0) local x = 0 local y = amount while x < y do workspace[cratetype]:Clone().Parent = workspace x = x + 1 end
end)
game.ReplicatedStorage.boxevent.OnServerEvent:Connect(function(player,asd,boxtype,amount)
    game.Players[asd].Crates[boxtype].Value = amount
end)

Thanks for helping. -- Nevermind, I fixed it myself long ago.

0
It seems as if asd is an object. Try doing [asd.Name] or you can just call asd.Crystals. I can't tell for sure or not without seeing the script firing the tempgui beeswithstingerss 41 — 4y
0
It is not a local-script. that is a server script that decides whenever the event is fired. What I mean by asd is the username defined by gui. Player was just there to fix another error i had. Frometa1998 35 — 4y
0
What actually is "asd"? User#27525 1 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Clearly the problem (and something I've seen in common) in all the error lines is this [asd] input. Check to see if those things are correct, and tell me more information about what [asd] is, and I might be able to explain it to you a little more in-depth.

(Update)

You're trying to access the admin gui, but with Screen Gui's you have to go through the player GUI and I believe this is a local script.

local plr = game:GetService('Players').LocalPlayer
game.ReplicatedStorage.moneyevent.OnServerEvent:Connect(function(asd,amount)
    game.ServerStorage.MoneyStorage[asd].Value = amount
end)
game.ReplicatedStorage.tempgui.OnServerEvent:Connect(function(asd)
    plr.PlayerGui.admingui.Contents.Visible = true
     plr.PlayerGui.admingui.Border1.Visible = true
     plr.PlayerGui.admingui.TempClose.Visible = true
end)
game.ReplicatedStorage.giveitem.OnServerEvent:Connect(function(asd,itemid,amount)
    game.ServerStorage.AwardItem:Invoke(itemid,amount)
end)
game.ReplicatedStorage.clearcrate.OnServerEvent:Connect(function(cratetype)
        for i,v in pairs(workspace:GetChildren()) do
            if v.Name == cratetype then
                v:Destroy()
            end
        end
    end)
game.ReplicatedStorage.ucevent.OnServerEvent:Connect(function(asd,amount)
        plr.Crystals.Value = amount
    end)
game.ReplicatedStorage.crateevent.OnServerEvent:Connect(function(asd,cratetype,amount)
    game.ServerStorage[cratetype]:Clone().Parent = workspace workspace[cratetype].Position = workspace[asd].HumanoidRootPart.Position workspace[cratetype].Position = workspace[cratetype].Position + Vector3.new(20,0,0) local x = 0 local y = amount while x < y do workspace[cratetype]:Clone().Parent = workspace x = x + 1 end
end)
game.ReplicatedStorage.boxevent.OnServerEvent:Connect(function(asd,boxtype,amount)
    plr.Crates[boxtype].Value = amount
end)

By the way, you don't have to put in player because when the event is fired, player is already sent in to the server script or other script, you just have to define it on the script it's firing to.

0
Alright, so asd is just the player name. i did not use plr cause i thought that would be the problem. but i used plr at first and it still didn't work so i switched to asd, asd does not work either Frometa1998 35 — 4y
0
So say game.Players:FindFirstChild('asd') JayShepherdMD 147 — 4y
0
Oh i see the problem, you are trying to access the gui. JayShepherdMD 147 — 4y
0
I can fix it JayShepherdMD 147 — 4y
View all comments (7 more)
0
yeah im trying to access the gui not asd as a actual player, lol. Frometa1998 35 — 4y
0
Alright, please answer it, that is if you're not writing it yet. Frometa1998 35 — 4y
0
Ok i've updated it JayShepherdMD 147 — 4y
0
Why not just use the actual "player" value sent over by default instead of sending one over? beeswithstingerss 41 — 4y
0
Wait, no it is not a local-script it is a server script Frometa1998 35 — 4y
0
By the way, you don't have to put in player because when the event is fired, player is already sent in to the server script or other script, you just have to define it on the script it's firing to. JayShepherdMD 147 — 4y
0
Try it now, everything is updated. JayShepherdMD 147 — 4y
Ad

Answer this question