Why won't it teleport on click?

Hello DevFourm Members! Today, I am trying to finish my Fort Jackson and the bus stops but I ran into a issue, it is taking the position for the HumanoidRootPart as nil.

Script:

 script.Parent.MouseButton1Click:Connect(function()
	local char = game.Players:GetPlayerFromCharacter(game.Players.LocalPlayer)
 	
	char.Position = CFrame.new(368.676, 14.803, -521.64)
 end)

Thanks,
TheKman2019.

3 Likes

normal script or local script??

2 Likes

Normal Script is the way I am doing it, here is a pic of the workspace.
image

1 Like

That’s an issue because normal scripts don’t work on local and visa versa

You can use a remote event to tell the server that the player clicked the button

1 Like

do u want it make the plr teleport toa certain place?

Mhm, it is a teleportation thing where you click the bus stop UI button and you get teleported to the bus stop location.

1 Like

Use the local script, it’ll use the ‘local’ function. Otherwise use this page for more information about the Teleport Module It’s from Developer hub!

1 Like

char.CFrame= CFrame.new(368.676, 14.803, -521.64)
try it


local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

local humrp = char:WaitForChild("HumanoidRootPart")

script.Parent.MouseButton1Click:Connect(function()

humrp.CFrame = CFrame.new(4,4,4) -- put what u want

end)
1 Like

or

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

script.Parent.MouseButton1Click:Connect(function()

char:MoveTo(position lol)

end)
```
2 Likes

You could do this:
LocalScript in starterplayerscripts:

local Button = game.Workspace["Bus Stop"].Airfeild --idk if this is in the startergui or not but ima think that its in the workspace, make any changes.
Button.MouseButton1Click:Connect(function(player)
	game.ReplicatedStorage.RemoteEvent:FireServer(player)
end)

Script in serverscripts:

game.ReplicatedStorage.RemoteEvent:Connect(function(player)
	if player then
		player.Position = CFrame.new(368.676, 14.803, -521.64)
	end
end)
1 Like

Maybe try teleporting the HumanoidRootPart instead.

Unfortunately, I tried it and it didn’t work.

That’s what I tried. Doesn’t work.

You’re tryna change the position of the character instance. Do this instead in a Local script:

 script.Parent.MouseButton1Click:Connect(function()
	local char = game.Players:GetPlayerFromCharacter(game.Players.LocalPlayer)
 	
	char.HumanoidRootPart.CFrame = CFrame.new(368.676, 14.803, -521.64)
 end)

Did you try mine or just the people that you responded to?

Won’t work since it requires many buttons to teleport, not just one button that it lets you teleport to.

Also, you were wrong about the workspace part. This is actually a GUI with bus stop locations you can teleport to, I had no problem changing it to the UI though.

So is a button on your screen on a button on a part?

@ianplus Doesn’t work.

@OfficerlSwearShes19 Tried it, doesn’t work.