Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make a script that keeps checking if a condition is met?

Ive used this code and it isnt working:

script.Parent.Touched:Connect(function(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) while true do if plr.leaderstats.Coins.Value >= 200 then script.Parent:Destroy() end end end end)

Pls tell me what i did wrong.

1 answer

Try to clean it up more and use code block so other people won't struggle to answer the question.

script.Parent.Touched:Connect(function(hit) 
local humanoid = hit.Parent:FindFirstChild("Humanoid") 
if humanoid ~= nil then 
local plr = game.Players:GetPlayerFromCharacter(hit.Parent) 
while true do 
if plr.leaderstats.Coins.Value >= 200 then 
script.Parent:Destroy() 
end 
wait(1)
end 
end 
end)

What is the purpose of the script? What does it say in the Developer Console (fn+f9) ?

This discussion is preserved as it was. New answers, comments, and votes are closed.