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

Is there a way to make a "variable function" run inside of a function?[SOLVED]

Asked by
danglt 185
5 years ago
Edited 5 years ago

What I mean by "variable function" is to have a premade function run. Ex:

function speed(p)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
end

script.Parent.MouseButton1Click:Connect(function()
--- Here would run "speed"
end

Sorta like how RemoteEvents Work

0
??? User#23365 30 — 5y
0
when you click the button it will make ur walkspeed = 0, from the function "speed" danglt 185 — 5y
0
Incorrect use of terminology can be very confusing for others. It's just called a 'function'. If I were to re-word your question, it would become "How do I call a function?". Your question could have been answered easily if you were willing to do a bit of research. Have a look at this wiki post for more on functions: http://wiki.roblox.com/index.php?title=Scripting_Book/Chapter_2 T0XN 276 — 5y

1 answer

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

??????

function speed(p)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
end

script.Parent.MouseButton1Click:Connect(function()
    speed() -- ?????

    --game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
    -- why dont you just set the speed in here?
end

?????

0
This is what is was looking for but I had already solved it on wiki. Ill still accept tho i guess danglt 185 — 5y
0
It was an example btw, but can i put the function "speed" in a module script and still play it from the module? danglt 185 — 5y
0
You can put it in a module script, then call it from a different script. DinozCreates 1070 — 5y
0
you can just not use an anonymous function and use the speed function as the first parameter of the connect function theking48989987 2147 — 5y
Ad

Answer this question