I want to make the GUI clonable only 1 time when touched not more. how can i do that ?
Camera = script.Parent.Parent.Parent.Camera1.Camera local ting = 0 function onTouched(hit) if ting == 0 then ting = 1 local check = hit.Parent:FindFirstChild("Humanoid") local character = game.Players.LocalPlayer.Character if check ~= nil then check.WalkSpeed = 0 character:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping, false) player = game.Players:findFirstChild(check.Parent.Name) game.Workspace.Camera.CameraSubject = Camera game.Workspace.Camera.CameraType = 1 exitgui = script.Parent.exitgui:clone() exitgui.Parent = player.PlayerGui end ting = 0 end end script.Parent.Touched:connect(onTouched)
GUI Script
character = game.Players.LocalPlayer.Character function Click(click) local player = game.Players.LocalPlayer if player == nil then return end game.Workspace.Camera.CameraSubject = player.Character.Humanoid game.Workspace.Camera.CameraType = 3 player.PlayerGui:findFirstChild("exitgui"):remove() character:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping, true) character.Humanoid.WalkSpeed = 16 end script.Parent.MouseButton1Click:connect(Click)
need help with walkspeed in GUI script please
Use local [var_name] = coroutine.wrap(function([name]) If you do this, the cloning will only work once. After that, it'll deny any more requests because the coroutine will already be dead by the time the gui clones. You can then load the coroutine by doing the following: Assume you do local x = coroutine.wrap(function() and put some stuff inside it. Once you do "x()" (or if you're going to connect it to something, it's "x") like you would with a normal function, the coroutine will load.