I have a script that i want it to teleport the player to a brick when he click on the gui button, everything of the script works but i dont get teleported and there is no error.

this is at line 13 that should make my player teleport, i tried with moveTo and with Vector3 instead of CFrame, didnt work either way.

local id = game.Workspace.Guards:GetChildren()
local spawn = game.Workspace.GuSpawns:GetChildren()
local player = script.Parent.Parent.Parent.Parent.Parent

function OnClicked()
	for i = 1,#id do
		if id[i].Value == "None" then
	        script.Parent.Parent.Parent.Parent.UI.Id.Value = id[i].Name
	        id[i].Value = player.Name
	        script.Parent.Parent.Parent.Parent.UI.Team.Value = "Guards"
	        for u = 1,#spawn do
		        if spawn["Spawn"..i] then
			        local spwn = spawn["Spawn"..i]
			        player.Character.Torso.CFrame = Vector3.new(spwn.Position.x, spwn.Position.y + 3, spwn.Position.z)
		        end
	        end
	        local ui = script.Parent.Parent.Parent.Parent.UI:GetChildren()
	        for o = 1,#ui do
		        if ui[o].ClassName == "Frame" then
		        ui[o].Visible = true
		        end
	        end
			    script.Parent.Parent.Parent.Parent.UI.Character:remove()
			    script.Parent.Parent.Parent.Parent.UI.Crafting:remove()
			    script.Parent.Parent.Parent.Parent.UI.Sections.Character:remove()
			    script.Parent.Parent.Parent.Parent.UI.Sections.Crafting:remove()
	        script.Parent.Parent.Parent:remove()
		else
		    script.Parent.Parent.Full.Gu.Visible = true
		    wait(3)
		    script.Parent.Parent.Full.Gu.Visible = false
	    end
	end
end

script.Parent.MouseButton1Click:connect(OnClicked)

5 comments

0

Why don't you just use the MoveTo Method?

0

^^

0

"i tried with moveTo and with Vector3" :/

0

Would you mind posting the full script?

0

there it is