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

Playing Tween Animations on Client?

Asked by 4 years ago
Edited 4 years ago

I'm trying to make a door that opens upon clicking the handle of the door, and I think if someone were to spam click the handle on the door, it would probably lag the server or just plain out annoy people. So I want it to play client so it would be smooth and not really laggy. Another example so you can better understand it: A player is sitting in a chair next to the door, another player joins the game and clicks the door handle and it opens, but on the player sitting on the chair doesn't see the door open; he just sees the other player just walk through the door. (Sorry if you can't read the code well, I'm new to this site)

Code used for the door: local TweenService = game:GetService("TweenService") local Door = script.Parent local Nob = Door.Nob local Nob2 = Door.Nob2 local Open = false local tweeninfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0) local tween = TweenService:Create(Door,tweeninfo,{CFrame = Door.Parent.DoorOpen.CFrame}) local tween2 = TweenService:Create(Door,tweeninfo,{CFrame = Door.Parent.DoorClosed.CFrame})

Nob.ClickDetector.MouseClick:Connect(function() if Open == false then tween:Play() Open = true wait(4) tween2:Play() Open = false end end)

Nob2.ClickDetector.MouseClick:Connect(function() if Open == false then tween:Play() Open = true wait(4) tween2:Play() Open = false end end)

0
shouldn't lag server if u have debounce Robowon1 323 — 4y
0
I just want it client side no matter what. Mr_WeffIe 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Copy your code, make a local script in StarterPlayerScripts, Paste your code in that local script, redefine the variables if you used script.Parent and stuff, and delete your normal script inside of your door. Now try it.

Ad

Answer this question