Hello.
I have created a script that works every time Humanoid sits or gets up from a chair.
Basically it works fine, but when the character dies or is reset, it stops working altogether.
I have found out that I can use “CharacterAdded” by looking in the forum.
I have actually improved the script, but apparently it still does not work after a reset.
What am I doing wrong?
local player = game.Players.LocalPlayer
local event = workspace.Events.RemoteEvent
local Character= player.Character or player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
player.CharacterAdded:Connect(function(chara)
Character = chara
humanoid = chara:WaitForChild("Humanoid")
end)
humanoid.Seated:Connect(function()
if humanoid.SeatPart then
if humanoid.SeatPart.Name == "VehicleSeat" then
event:FireServer(sit)
print("sitdown VS")
else
event:FireServer(nil)
print("sitdown")
end
else
event:FireServer(nil)
print("standup")
end
end)
This LocalScript is stored in StarterPlayerScript.