Hi, is there an code that lets you fire a script when a other script is fired for example:
local function script1()
if Money.Value == 15 or 20 or 25 or 30 or 35 or 40 or 45 or 50 then
player.PlayerGui.shopkeeper.Enabled = true
for i, v in pairs(shopkeeperDialogCheeseburger) do
for i = 1, string.len(v) do wait(0.025)
player.PlayerGui.shopkeeper.shopkeeperText.Text = string.sub(v, 1, i)
end
wait(string.len(v) / 10)
end
player.PlayerGui.shopkeeper.Enabled = false
Money.Value -= 15
end
end
if script1 --when it fires i want it will continue the code
then print("fired")
end
do you mean like this, or what is the prob?
idk lmk
local remoteEvent = game.ReplicatedStorage.anything
local function script1()
if Money.Value == 15 or 20 or 25 or 30 or 35 or 40 or 45 or 50 then
player.PlayerGui.shopkeeper.Enabled = true
for i, v in pairs(shopkeeperDialogCheeseburger) do
for i = 1, string.len(v) do wait(0.025)
player.PlayerGui.shopkeeper.shopkeeperText.Text = string.sub(v, 1, i)
end
wait(string.len(v) / 10)
end --the part in the 5 brackets is not working
player.PlayerGui.shopkeeper.Enabled = false
Money.Value -= 15
end
end
if script1 then
remoteEvent:FireServer() – remote fires script
end
Before i help solve your main question, i need to point out an important issue with your code.
This line of code will not work, you cannot say or number or number etc, as it will actually say or false.
Instead you should store all the numbers in a table like this
local moneyTable = {15,20,25,30,35,40,45,50}
if table.find(moneyTable,15) then blah
Now for your main question, if you want to fire/call your function “script1” without yeilding or pausing the entire script until it finishes, you would want to spawn a new thread.
The easiest way to do this is using task.spawn
Here is your script with the changes ive mentioned, it should work however im at school so i cant test it
local moneyTable = {15,30,25,30,35,40,45,50}
local function script1()
task.spawn(function()
if table.find(moneyTable, Money.Value) then
player.PlayerGui.shopkeeper.Enabled = true
for i, v in pairs(shopkeeperDialogCheeseburger) do
for i = 1, string.len(v) do wait(0.025)
player.PlayerGui.shopkeeper.shopkeeperText.Text = string.sub(v, 1, i)
end
wait(string.len(v) / 10)
end --the part in the 5 brackets is not working
player.PlayerGui.shopkeeper.Enabled = false
Money.Value -= 15
end
end)
end)
if script1 --when it fires i want it will continue the code
then print("fired")
end