Im trying to make it so that if a player is in group and clicks a ui button it teleports them to a certain position

I don’t know what i messed up with here, its a local script btw.


1 Like

set the cframe of humanoidrootpart

1 Like

The Problem with this code is the player.Character:SetPrimaryCFrame(), to change a players CFrame this isnt used, we dont change the character’s primary CFrame, we change the Humanoid CFrame, to fix this problem you have to change the humanoidRootPart like this:

local player = game.Players.LocalPlayer
local button = script.Parent

script.Parent.MouseButton1Click:Connect(function()
	if player:IsInGroup(33552053) then
		player.Character.HumanoidRootPart.CFrame = CFrame.new(-1614.789, 56.033, -824.892)
	else
		print("no")
	end
end)

player.Character:PivotTo(…)
is an alternative method for :SetPrimaryPartCframe
so it would look like this:

local player = game.Players.LocalPlayer
local button = script.Parent

script.Parent.MouseButton1Click:Connect(function()
	if player:IsInGroup(33552053) then
		player.Character:PivotTo(
           CFrame.new(-1614.789, 56.033, -824.892)
        )
	else
		print("no")
	end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.