Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Sword giver wont run?

Asked by 9 years ago

I have a loop that will turn the value on and off as well as a few other things but when the value is changed, this script isn't effected. Any Ideas?

if game.workspace.Gamestart.Value == true then
    wait(0.1)
     local sword = game.ReplicatedStorage.ClassicSword:Clone()
     sword.Parent = game:GetService("Players").LocalPlayer.Backpack
     sword.Handle.Mesh.TextureId = script:WaitForChild("TextureId").Value
end

1 answer

Log in to vote
0
Answered by 9 years ago

Try using the "Changed" event, whenever the value has change (like from false to true and the other way round) It will register and start the code.

function onChanged()
if game.Workspace.Gamestart.Value == true then
--code
elseif game.Workspace.Gamestart.Value == false then
--code
end
end
end
game.Workspace.Gamestart.Value.Changed:connect(onChanged)
Ad

Answer this question