0

# How do I execute a script depending on a string value?

I've tried 2 attempts at this, I'm putting both of them here. But I know it's the top part that isn't working right but I can't find out why. When I put everything under "then" in a onclicked script it works perfect. I'm confused, anything helps.

while true do
RedBall = game.ReplicatedStorage.RedBall
if RedBall.Value == "true"
then
newItem = game.ReplicatedStorage.Football.Handle:Clone()
newItem.Handle.CFrame = CFrame.new(-189.549, 1.8, -37.55)
newItem.Parent = workspace
end
end


2nd Attempt

while true do
if game.ReplicatedStorage.RedBall.Value == "true"
then
print("gg")
newItem = game.ReplicatedStorage.Football.Handle:Clone()
newItem.Handle.CFrame = CFrame.new(-189.549, 1.8, -37.55)
newItem.Parent = workspace
end
end


0
while true do
if game.ReplicatedStorage.RedBall.Value == "true" then
print("gg")
local newItem = game.ReplicatedStorage.Football.Handle:Clone()
newItem.Handle.CFrame = CFrame.new(-189.549, 1.8, -37.55)
newItem.Parent = workspace
end
wait(.1)
end


The script is prob not working because you didn't put a wait in the while loop so roblox automatically stops the script otherwise it would of crashed ur game. You can try just wait() as well for even faster.