Hello I am making a roblox LUA script and I cant figure out how to make the script stop after a if sentence. Here my code.
if not newPlayer:GetRankInGroup(workspace.CoreValues.GroupID.Value) then
teamName = "Civilian"
(STOP)
end
Hello I am making a roblox LUA script and I cant figure out how to make the script stop after a if sentence. Here my code.
if not newPlayer:GetRankInGroup(workspace.CoreValues.GroupID.Value) then
teamName = "Civilian"
(STOP)
end
Depending on how you structure your code, you could simply return
.
local shouldEscape = true
if shouldEscape then
return
end
print("This line won't get hit")
But if you have set up event listeners, this won't stop those from firing. You'll need to clean those up, disable the Script, or delete the Script.
-- connect to a signal as an example
local connection = game.Players.PlayerAdded:Connect(function(player)
-- if the Script is still enabled, this line will print
print("Player Added : " .. player.Name)
end
local shouldEscape = true
if shouldEscape then
-- disable the script
script.Disabled = true
-- OR : disconnect the signals
--connection:Disconnect()
-- OR : delete the script entirely
--script:Destroy()
-- escape so that no other lines execute
return
end
print("This line won't get hit")