local adobeSpawn = game.Workspace.AdobeSpawn local homeSpawn = game.Workspace.HomeSpawn local dilSpawn = game.Workspace.DilapidatedSpawn local torso = script.Parent.Parent.Parent.Parent.Character.Torso while true do local Place = math.random(1, 3) function onClicked() wait(1) if Place == 1 then torso.CFrame = CFrame.new(Vector3.new( -30.855, 4.6, -72.677 )) end if Place == 2 then torso.CFrame = CFrame.new(Vector3.new( 108.483, 6.32, -128.738 )) end if Place == 3 then torso.CFrame = CFrame.new(Vector3.new( 24.163, 5.33, -204.628 )) end end end
script.Parent.MouseButton1Click:connect(onClicked)
You inserted click function into while true do
code, and thats confusing. Explanations are in script.
local adobeSpawn = game.Workspace.AdobeSpawn local homeSpawn = game.Workspace.HomeSpawn local dilSpawn = game.Workspace.DilapidatedSpawn local character = script.Parent.Parent.Parent.Parent.Character --Instead of searching for torso, we will search for character function onClicked() --Instead of moving torso, we moving whole player by primary part CFrame, and Vector3 is needed only when we need to use ":MoveTo()". Player's primary part is Head, so bare in mind. if Place == 1 then character:SetPrimaryPartCFrame(CFrame.new(-30.855, 4.6, -72.677)) end if Place == 2 then character:SetPrimaryPartCFrame(CFrame.new(108.483, 6.32, -128.738)) end if Place == 3 then character:SetPrimaryPartCFrame(CFrame.new(24.163, 5.33, -204.628)) end end script.Parent.MouseButton1Click:connect(onClicked) --Function and "while true do" are separated from each other to prevent script confusion. while true do local Place = math.random(1, 3) wait(1) end --Don't forget to put "while true do" in the end of the script, otherwise function won't run.