I've noticed some grammar mistakes, lmao. Maybe some terminology errors too, I hope I helped though
repeat wait()
Player = game.Players.LocalPlayer
Button = script.Parent
Magic = game.ServerScriptService:FindFirstChild("Fireball")
until
Button.MouseButton1Down:connect(function(purchase)
if 1+1==2 then
local a = Magic:Clone()
a.Parent = Player.PlayerScripts
end
end)
This would not work at all.
Before I go on, just a tip of advice:
if 1 + 1 == 2 then
is completely unnecessary...it doesn't do anything either.
Basically you can't do until for until a signal is connected to a function.
Yeah, that didn't even make sense or sound right when I said it.
Now I'll go on.
repeat wait()
and until
is pretty useless.
You can just incorporate these values in the beginning of the script, like so:
local Player = game.Players.LocalPlayer
local Button = script.Parent
local Magic = game.ServerScriptService:FindFirstChild("Fireball")
I mean, there's no point of repeating this until a button is clicked.
You could then have a BindableFunction in the players Backpack,
so put one in StarterGui if you don't want to use a script to insert it.
local Func = Player.Backpack.Function
Now let's invoke Func when the signal is called (or whatever, I haven't been scripting for a while now, please excuse my vocabulary and terminology if it is incorrect)
Like this:
Button.MouseButton1Down:connect(function(purchase)
local a = Magic:Clone()
a.Parent = Player.PlayerScripts
Func:Invoke(true)
end)
Now let's receive the Invoke with a simple function, and then do whatever you wanted after.
I assume you wanted to do something after the button was clicked. You tried to make it repeat something (not needed) until the button was clicked, anyways:
I recommend making a "MainFunction" to do whatever you wanted to do after the buttons clicked. Example:
local function MainFunction()
print(1 + 1)
end
local function isn't needed, don't you dare criticize me on that.
function Func.OnInvoke(whateveryouwanthereitcanbeusefulLater)
MainFunction()
end
Simple as that, but there are easier ways to do this like with a value. Now you may be saying what if they press the button more times, no they won't just delete the button or make a boolValue that must be true to OnInvoke and then turn it off after the press.
So all together:
local Player = game.Players.LocalPlayer
local Button = script.Parent
local Magic = game.ServerScriptService:FindFirstChild("Fireball")
local Func = Player.Function
local function MainFunction()
print(1 + 1)
end
function Func.OnInvoke(whateveryouwanthereitcanbeusefulLater)
MainFunction()
end
Button.MouseButton1Down:connect(function(purchase)
local a = Magic:Clone()
a.Parent = Player.PlayerScripts
Func:Invoke(true)
end)
I really hope that I helped, if I didn't I at least I hope I educated you on some other stuff in coding
Hope I helped, have a great day. Oh and if my vocabulary is off or if nothing makes sense I'm sorry feel free to make fun of me in comments :(
3 comments
This is definitely wrong.
Do you even know how repeat until works? IT DOESNT REQUIRE AN END. "repeat code until stament" - NO END.
oml