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

Making key giving gui system but an error shows up and it wont work?

Asked by
RootEntry 111
5 years ago

Hi,

I am scripting a gui that gives the specified player a room.

But when I try it the serverside get's a error.

It's FE.

game:GetService("ReplicatedStorage").GiveKey.OnServerEvent:Connect(function(Player, PlayerName, RoomNumber)
        if not workspace.RoomDoors.RoomsTaken:FindFirstChild(RoomNumber.Text) then

            local Target = game.Players:FindFirstChild(PlayerName.Text)

            if Target then
                -- Room is not Taken
                print("Not Taken")
                local NewValue = Instance.new("StringValue", workspace.RoomDoors.RoomsTaken)
                NewValue.Name = RoomNumber.Text
                NewValue.Value = Target.Name

                Player.PlayerGui:WaitForChild("Board").Frame:FindFirstChild("Room "..RoomNumber.Text).Taken.Value = true

                local RoomKey = game:GetService("ReplicatedStorage").Keys:FindFirstChild("Room "..RoomNumber.Text)
                RoomKey.Parent = Player.Backpack
            end
        else
            local Target = game.Players:FindFirstChild(PlayerName.Text)

            -- Already has a room
            if Target then
                -- Room is Taken
                print("Taken")
            end

        end
end)

game.Players.PlayerRemoving:Connect(function(Player)
    for i,v in pairs(workspace.RoomDoors.RoomsTaken:GetChildren()) do
        if v.Value == Player.Name then
            v:Destroy()
        end
    end
end)

Error: "17:16:16.065 - ServerScriptService.DoorSystem_SERVER:2: attempt to index local 'RoomNumber' (a nil value)"

0
a nil value means it dose, well try this https://www.robloxdev.com/articles/Nil helleric -3 — 5y
0
It means that it's not a valid object, it means nothing; no value assigned to it. It's absolutely nothing, as defined in Lua. I'm sure that it doesn't take a PlayerName, but rather a Player, and that you need to return some sort of table, not object (because that's not how remote event arguments work). You should send the text first, not the object; but send the text and receive the text, not obj SmartNode 383 — 5y
0
what, it's because in FireServer the argument sent was nil or they didn't send any at all, still making it nil lol User#19524 175 — 5y

Answer this question