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)"