Issue with gate not opening

Hey! So I am making a gate and this is what it looks like in the Model

Gate


Everything is unanchored except “Main” and everything is welded to main.

Now, what I am trying to achieve is, when I click a button, the gate Opens.

Click Detector
In Explorer

image

The Script
local Cool = workspace.Part
script.Parent.MouseClick:Connect(function()
	game.ReplicatedStorage.Gate.Open:FireServer()
end)
Replicated Storage

image

ServerScripterService
In Explorer

image

The Script
local Gate = workspace.GateS.Gate:WaitForChild("Main")

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	
	0.5,
	Enum.EasingStyle.Bounce,
	Enum.EasingDirection.InOut,
	0,
	false,
	0
)

local GateOpen  = {CFrame = CFrame.new(-244.679, 16.044, -34.469)}

local tweenOpen = TweenService:Create(Gate, tweenInfo, GateOpen)





game.ReplicatedStorage.Gate.Open.OnServerEvent:Connect(function(player)
	
	print("Cli")
	tweenOpen:Play()
	
end

I dont get anything in the Output nor does the gate move.

Any help would be appreciated :slight_smile:

what is the clickdetector part’s parent?

30 chars

edit: part’s parent,

image

So the part is just in the workspace

you cant use localscripts in the workspace

For the ClickDetector, change the local script to a script, then put the ServerScriptStorage script inside the script inside the ClickDetector.

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

So do I not need a remote event or something?

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)

Doesnt seem to work, does it have to be anchored or unanchored

it was a little typo, sry, edited

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)}