Local script not calling function on touched/touchended

Hi. I’m trying to create a script that when you touch a pressure, it fires a remote event to open the door, but then once you step off it, it closes. I’m unsure on why the functions aren’t being called when it’s being touched. Any idea why?
PS. I’m kind of a beginner, so if you could explain simply that’d be nice.

ReplicatedStorage = game:GetService("ReplicatedStorage")

Step = ReplicatedStorage.Pressure1step

Off = ReplicatedStorage.Pressure1off

local function step()

print("step called")

Step:FireServer()

print("fired step")

end

local function off()

print("off called")

Off:FireServer()

print("fired off")

end

script.Parent.Touched:Connect(step)

script.Parent.TouchEnded:Connect(off)

Where is that local script located in?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Step = ReplicatedStorage:WaitForChild("Pressure")

local function step()
	print("step called")
	Step:FireServer(true)
	print("fired step")
end

local function off()
	print("off called")
	Step:FireServer(false)
	print("fired off")
end

script.Parent.Touched:Connect(step)
script.Parent.TouchEnded:Connect(off)

Also, you could shorten that and have a single remote for it. Just pass true/false accordingly and act accordingly on the server side aswell.

Inside of the pressure plate. And yeah I know I could technically shorten it but I don’t really understand passing data with remote events.

i think you don’t need event
make it with event will be hard

Where did you put the local script?

I need it to be opened on the server, though. I don’t want it opened on the client.

Inside the pressure plate to open the door.

You cannot have a local script inside the workspace, you could use a server script for this instead.

1 Like

use a server script instead!
Also do not format your scripts like this!
You should do as valkyrop suggested

1 Like

Didn’t know. Thanks for the info.