So im making a admin panel and theres a button to teleport to players and this script automaticlly starts for some reason even tho i didnt click the button for it to start im still a starter can someone please help me~~~~~~~~~~~~~~~~~ if script.Parent.MouseButton1Click then local p1 = game.Players.LocalPlayer.Character.HumanoidRootPart local p2 = "InsertPlayerHere"
local pos = p1.CFrame p2 = script.Parent.Parent.Player.Text p1.CFrame = game.Players[p2].Character.HumanoidRootPart.CFrame p1.CFrame = pos end
~~~~~~~~~~~~~~~~~
In your script, you're trying to check if MouseButton1Click
exist inside script.Parent
, and it exists because it's an event and event will automatically be put inside an instance by the roblox game engine. Instead, use events properly like this script below.
script.Parent.MouseButton1Click:Connect(function() local p1 = game.Players.LocalPlayer.Character.HumanoidRootPart local p2 = script.Parent.Parent.Player.Text local pos = p1.CFrame p1.CFrame = game.Players:WaitForChild(p2).Character.HumanoidRootPart.CFrame end)
I hope the script above works and I hope this helped! ^^
Learn more about events: Documentation Wiki Fandom