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?
--LocalScript in StarterPlayerScripts if game.Players.LocalPlayer.UserId==438845010 then workspace.Throne.Seat.Disabled=false end
--ServerScript: --workspace.Throne.Seat.Disabled=true
Create a Script inside of a Seat and paste this code inside of it. Make sure to type your name in the variable correctly.
local OwnerName = " Owner Name " -- Type Seat Owner's Name script.Parent.ChildAdded:Connect(function(Part) if Part.Name == "SeatWeld" then if Part.Part1.Parent.Name == OwnerName then print("OwnerSitting") else wait(0.1) Part.Part1.Parent.Humanoid.Sit = false end end end)
The script is much Shorter but is efficient.