i made a script that allow only me to sit in a Throne, its working, but i need to touch the seat like 3-5 times until i sit, it shows this until it work:
14:27:05.409 Workspace.BaragganThroneRemote.Seat.PermToSit:10: attempt to index nil with 'CharacterAdded' - Server - PermToSit:10
my script is this:
local allowed = {438845010}
local players = game:GetService("Players")
local seat = script.Parent
seat.Disabled = false
seat.Touched:Connect(function (hit)
if seat.Occupant then return end
local player = players:GetPlayerFromCharacter(hit.Parent)
local Character = player.CharacterAdded:Wait()
for i = 1, #allowed do
if allowed[i] == player.UserId then
local humanoid = player.Character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
seat.Disabled = false
end
else
seat.Disabled = true
end
end
end)
wt am i doing wrong? can i do something that i just sit and its it, dont fail like 3 times until work?
