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

Run a script with a clickdetector?

Asked by 7 years ago

How do i run a script with a clickdetector button?

0
I want to run a math random script with a click detector epiczombiehunter232 0 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

I am assuming you are decently new to Roblox Lua Scripting. So I am going to give you just some ideas of what you will need, and you can find it on the wiki! A good way to make a clickbutton run a script, is creating a function You put what you want to happen inside the function, and then you call the script with an event. You can find events in the Object Browser. However if you wanted to make it so when the block is clicked you would use

function NameFunction
(What you want to happen)
end

This function is not done yet, you need to call the function. In order to do that, you can use an event/listener. There are many events or listeners in the object browser. They can be found as the little yellow lightning symbol. In this instance, you will go inside the ClickDetector and call the MouseClick listener. Like so:

game.Workspace.Part.ClickDetector.MouseClick:connect(NameFunction)

Anyways, there are a lot of things you can do with functions, with many events and listeners to use from! Whether it's making a slot machine, boat, planes, anything you want! Happy scripting, hope this helped! I can't exactly make the script for you, as it is against the rules. However, for all of your scripting needs, go to the wiki before coming here. If you can't find anything on the wiki then come here. :)

0
or you can do game.Workspace.Part.ClickDetector.MouseClick:connect(function() loulou1112 35 — 7y
0
Just a tip, it should be function NameFunction(--[[Parameters]]) --[[Logic Here]] end M39a9am3R 3210 — 7y
Ad

Answer this question