i have been trying to make a script where if the player clicked something they teleported and then did an animation and then whenever they want to desist the animation they would press a local surface gui but it isnt working i put the script in a local script inside a block which is in a model and inside the model is a block where they teleport and the block where they click the block where they click should have a surface gui which they click to be teleporting them out and then un anchoring then stopping the animation them but its not working. help?
local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=144911345" --animation id here local playar = game.Players.LocalPlayer.Character local plyer = game.Players.LocalPlayer.numbv local lol = Instance.new("NumberValue") local animTrack = nil local canPlay = true local Players = game:GetService("Players") local plac = script.Parent.Parent.tpplace.CFrame print("script loaded") function onClicked(Players) if canPlay == true and playar.numbv.Value == 0 then local numbv = false print("clicked and carried") canPlay = false if playar == nil then return end print("nill done") local animTrack = playar.Humanoid:LoadAnimation(animation) animtrack playar.Torso.CFrame = CFrame.new(plac) player.Torso.Anchored = true print(plac) print("doneall") wait(0.1) end end script.Parent.ClickDetector.MouseClick:connect(onClicked) player.Torso.Anchored = false player.Torso.CFrame = CFrame.new(plac end end function surfacegui(Players) script.Parent.surfacegui.MouseClick:connect(surfacegui) function onPlayerAdded(Player) local lol = Instance.new("NumberValue") lol.Parent = playar lol.Name = "numbv" lol.Value = 0 print("value did") end Players.PlayerAdded:connect(onPlayerAdded) for _,player in pairs(Players:GetPlayers()) do onPlayerAdded(player) end
if you could help, thanks :D
Maybe include an event and on event you fire the animation.