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

help with fixing a code involving teleportation?

this code is not throwing up errors and in theory (in my head) it should work i honestly don't know what to do any help?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
	local CharacterModel = player.Character 
    	 
    CharacterModel:SetPrimaryPartCFrame(CFrame.new(1, 0, 1) * CFrame.Angles(math.rad(0), math.rad(80), math.rad(0)))
    wait(1)
  end)
end)

3 answers

Seems good, the only wrong i see is local CharacterModel = player.Character That should be local CharacterModel = player.character So try that. Because you did player.Character.Added:Connect(function(character) so it's character not Character.

2 comments

0

i tried this but it still did not work

0

Ur wrong its player.Character or character the latter is the parameter

Hello ,while I don't really know what's wrong with it here try this out it might work:

game.Players.PlayerAdded:Connect(function(p)	  	
	p.CharacterAdded:Connect(function(char) 
			local CF = CFrame.new(1, 0, 1) * CFrame.Angles(math.rad(0), math.rad(80), math.rad(0))
		    char.HumanoidRootPart.CFrame = (CF)
			wait(1)
	end)
end)

1 comment

0

this does nto work either but maybe because i put it in the wrong place? right now it is in the workspace

this is a script right? Use then the GetService for the players like this, i have to many times an event not fire bc someone didnt use the service and the playerloaded faster in than the event got connected

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
    -- why save the character in a temp variable when u already have it as a parameter ?????
	-- its better than you change the CFrame of the HRT
	character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(1, 0, 1) * CFrame.Angles(math.rad(0), math.rad(80), math.rad(0)) -- i am not sure if you know what this actually does
   -- no wait needed literally serves no purpose
  end)
end)

1 comment

0

unfortantly this did not work for me, does it work in your world? and yes i do know what it does it is supposed to relocate the player and turn them so they are facing a certain direction. the reason why is long if you want me to explain i can. thank you for your help :)

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