like @Septhoren said, put the ServerScriptService inside the part, and delete the localscript, and change the script to:
local Gate = script.Parent
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.InOut,
0,
false,
0
)
local debounce = false
Gate.ClickDetector.MouseClick:Connect(function(player)
local GateOpen = {CFrame = CFrame.new(-244.679, 16.044, -34.469)}
local tweenOpen = TweenService:Create(Gate, tweenInfo, GateOpen)
if not debounce then -- so it wont play more than once
debounce = true
tweenOpen:Play()
-- optional: Gate.ClickDetector:Destroy()
wait(2)
debounce = false
end
end
not really, unless you want a tween on the client which is smoother but only makes the gate open for the player that fired the event, (unless you replicate it to the server)
I say change the locsl script into a regular script under the click detector and then assign the same code that was under your local scropt to the script. If you want the door to open only on the client side, you would have to use a remote event to fire to a local script to open the door on the client side.
Also events like MouseClick DO NOT run on local script as they will only work on regular scripts. That’s why a remote event would be useful to use if you need it to happen only on the client side
local Gate = workspace.GateS.Gate.Main
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Elastic,
Enum.EasingDirection.InOut,
0,
false,
0
)
local GateOpen = {CFrame = CFrame.new(-254.279, 16.044, -41.269)}
local TweenOpen = TweenService:Create(Gate, tweenInfo, GateOpen)
local debounce = false
script.Parent.MouseClick:Connect(function()
if not debounce then
debounce = true
Gate.Sound:Play()
TweenOpen:Play()
print("Clicked")
wait(2)
debounce = false
end
end)
Now, I tried it in another game and it worked, I copied the same thing into the game and it didnt work, could it be an infection or maybe some other script interfering?
Its hard to tell whats wrong. But i will suggest u to make a new tween every time the player clicks the button and make the tween’s cframe relative to its current position (
local Goal = {["Position"]=Vector3.new(Gate.Position.X-Gate.Size.X ,Gate.Position.Y,Gate.Position.Z)}