Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

CFrame Teleportation not working? Touched Part Event.

I'm trying to create a simple teleportation. What I'm trying to do is make it like when you reach the end of the obby, you get points and then you teleport back to the brick. For some reason, it's not working and I don't know why. I'm attempting to teleport the HumanoidRootPart. (Also, the leaderstats value is not working but I'll post a separate question later.)

The descendants goes like this: game.Workspace.Folder.Part

workspace.ObbyStuff.GetPoints.Touched:Connect(function(hit)
	local brick = workspace.ObbyStuff.Teleporter
	local debounce = false
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		if not debounce then
			debounce = true
			local plr = game.Players[hit.Parent.Name]
			hit.Parent.HumanoidRootPart.CFrame = brick.CFrame
			plr.leaderstats.Points.Value = plr.leaderstats.Points.Value + 100
			wait()
			debounce = false
		end
	end
end)

I have no idea why it is not working, and I would like help to solve this issue. No errors at least from what I see. Any help is appreciated, because I am [Visible Confusion].

3 comments

0

Sometimes I use print() to debug, such as seeing where the code gets to before stopping.

0

I ask the question I was confused about dovy

0

iivSnooxy What??????

2 answers

Try changing

hit.Parent.HumanoidRootPart.CFrame = brick.CFrame

to

hit.Parent.HumanoidRootPart.CFrame = brick.Position

1 comment

2

why would u change cframe to a vector3??

Try replacing hit.Parent.HumanoidRootPart.CFrame = brick.CFrame with

hit.Parent:SetPrimaryPartCFrame(brick.CFrame)

This discussion is preserved as it was. New answers, comments, and votes are closed.