The script is suppose to swap out the fake briefcase with the real brief case when a player touches the fake brief case but, it won't do it unless an intvalue is at 100.
Code for the briefcase swapper;
if script.Parent.Value.Value >= 99 then while wait() do game.Workspace.BriefcaseClone.Handle.Touched:connect(function() wait(0.001) local clone = game.ReplicatedStorage.Briefcase:Clone() wait(0.001) game.Workspace.BriefcaseClone:Destroy() wait(0.001) clone.Parent = game.Workspace end) end end
I have another code that adds 1 point to the IntValue once it gets clicked;
script.Parent.ClickDetector.MouseClick:connect(function(c) script.Parent.Value.Value = script.Parent.Value.Value + 1 end)
Help.
You weren't clear, but if the IntValue has nothing to do with that, and if you only want the tools to swap, then, try this:
game.Workspace.BriefcaseClone.Handle.Touched:connect(function() game.Workspace.BriefcaseClone:Destroy() local clone = game.ReplicatedStorage.Briefcase:Clone() clone.Parent = game.Workspace end)
But, if you actually want to that action be executed ONLY if that IntValue is 99 or bigger, then...
game.Workspace.BriefcaseClone.Handle.Touched:connect(function() if script.Parent.Value.Value > 98 then --I don't like using >= nor <= and that already failed some times to me, so, I'll just use > and less 1 value. game.Workspace.BriefcaseClone:Destroy() local clone = game.ReplicatedStorage.Briefcase:Clone() clone.Parent = game.Workspace end end)
If this works for you, mark this answer as the solution, please. If this won't work, leave a comment telling why, and giving possible errors.
As always, good scripting! ;)
Sometimes giving the clone a parent after you have cloned it is the right way to do it, try switching the destroy and parenting line out and seeing how it runs.
And also, the script.Parent.Value.Value line, is the script.Parent.[Value].Value the name for the actual int value?