I’m trying to create a script where when a player presses their screen while they are holding a tool and sitting in a specific seat, an animation will play for the player and the seat. This is in a local script, no errors printed.
script.Parent.Equipped:connect(function(m)
local hum = script.Parent.Parent:WaitForChild("Humanoid")
if hum.Seated then
function Seated (seated, seat)
m.Button1Down:connect(function()
print(seat.Name)
local Animator1 = seat.Parent.Ring1.AnimationController.Animator
local Animator2 = seat.Parent.Ring2.AnimationController.Animator
Animator1:LoadAnimation(script.Parent.Rings):Play()
Animator1:LoadAnimation(script.Parent.Rings):Play()
hum:LoadAnimation(script.Parent.Player):Play()
end)
end
hum.Seated:Connect(Seated)
end
if not hum.Seated then
return
end
end
There is quite a bit of issues here doesn’t seem like you fully understand how events and functions work
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
Tool.Activated:Connect(function()
if Humanoid.Seated then
local Ring1 = Humanoid.SeatPart:FindFirstChild("Ring1")
local Ring2 = Humanoid.SeatPart:FindFirstChild("Ring2")
if RIng1 and Ring2 then
local Track1,Track2 = Ring1.AnimationController.Animator:LoadAnimation(put obj here),Ring2.AnimationController.Animator:LoadAnimation(put obj here)
while Track1.Length <= 0 or Track2.Length <= 0 do print("Loading") task.wait() end
Track1:Play(); Track2:Play()
end
end
end)
Here is a code example of how you should probably go about this, This will not work if directly put in modifications are needed, also keep in mind that local scripts only work when parented under a player/character object
If you want more in-depth/quicker assistance you can contact me on discord Thedagz#4176