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

Is there anyway to run seat.Changed or something similar on a local script?

Asked by 3 years ago

I need to run a script when a seat that is copied locally has a player seated.

0
Maybe I didn't word that the best. What I meant was. There's a seat that is copied by a local script from ReplicatedStorage and this seat needs to detect when a player is seated so then fires to the server for certain actions. jamespringles 105 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

There certainly is. The way to do this, is everytime the seat changes, check the if the seat occupant is equal to the character Humanoid.


local plr = game.Players.LocalPlayer -- get the player local chr = plr.Character or plr.CharacterAdded:Wait() -- get the character, if its not there then wait. local humanoid = chr:WaitForChild("Humanoid") -- wait for the character humanoid local seat = game.Workspace:WaitForChild("SeatName") -- wait for the seat seat.Changed:Connect(function() -- when seat changes, perform this function if seat.Occupant == humanoid then -- if the humanoid is in the seat, run this code -- do whatever when they sit in it. end end)

I hope this helps!

0
when i did seat.Changed for a local script it didn't seem to work jamespringles 105 — 3y
0
thats because localscripts only run either; under replicatedfirst, playergui, backpack, player character or playerscripts. Sebgamingkid 147 — 3y
Ad

Answer this question