I want to make it so the clickdetector runs a different script. However I am new and don't know where to start.
COMMUNITY QUESTION
Run a script with a clickdetector?
1 answer
I'm assuming you mean when you click a part it runs another script if so then this is the answer.
SETUP: First, you would need a remote event for the two scripts to communicate with each other. To do this you simply go into ReplicatedStorage and add a new RemoteEvent and call it ( MyRemoteEvent )
This first script is going to be in your part:
local part = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
part.ClickDetector.MouseClick:Connect(function() -- When someone clicks the part it runs this code below
local MyRemoteEvent = ReplicatedStorage:WaitForChild("MyRemoteEvent") -- getting the remoteevent that you made previusly
MyRemoteEvent:FireServer() -- Activates the event so the other script knows when to start going.
end)
This is the other script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MyRemoteEvent = ReplicatedStorage:WaitForChild("MyRemoteEvent") -- The RemoteEvent you made previusly
MyRemoteEvent.OnServerEvent:Connect(function() -- When the first script is touched this code under will run
-- From here you just put your code in here and it should work
end)
https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
if this helped you please accept my answer :D
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Please elaborate
You need to give us more information on your problem. I cant tell what the problem is.