Event not teleporting

Hello i’m making a proximityprompt that teleport every players once its triggered but it doesnt work

if workspace.ProximityPrompt.ProximityPrompt.Triggered:Connect(function()
		game.ReplicatedStorage.googoogaga:FireServer()
	end) then
end

Located on StarterGui.

game.ReplicatedStorage.googoogaga.OnServerEvent:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = CFrame.new(223.612, 12.68, 22.188)
end)

Script on ServerScriptService

It does work but it’s not teleporting everyone

It should be game.ReplicatedStorage.googoogaga:FireAllClients().

Nothing has changed , not teleporting EVERYONE in the same position that I want

1 Like

Add a print in here, does it even print out?

Yes but it’s not teleporting every players

1 Like

Try this out:

local RS = game:GetService("ReplicatedStorage")

local event: RemoteEvent = RS.googoogaga

event.OnServerEvent:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
	
	char:SetPrimaryPartCFrame(CFrame.new(223.612, 12.68, 22.188))
end)

It’s still not teleporting every players

the problem is that you’re only getting the player that triggered the prompt and teleporting that player. I suggest instead using a for loop to loop through the players and then teleporting them all. It would be something like this

local Players = game:GetService("Players")

for _, v in pairs(Players:GetPlayers()) do
      v.Character.HumanoidRootPart.CFrame = CFrame.new(223.612, 12.68, 22.188)
end)

also, it might be better to use PivotTo() instead of changing the CFrame of their HumanoidRootPart.

local Players = game:GetService("Players")

for _, v in pairs(Players:GetPlayers()) do
      v.Character:PivotTo(CFrame.new(223.612, 12.68, 22.188))
end)

you could use either but I’d use PivotTo() since it can be used to move the entire model in other cases

I don’t see anything mentioning the ProximityPrompt.

Actually, the thought completely went through my mind. Why are you teleporting them in the client? It’s probably better to loop through the players and teleport them on the server instead (like what @Bonusizawesome mentioned).

my code didn’t include the proximity prompt. this is not the full code, but an example. I can add the rest of it if you’d like

local Players = game:GetService("Players")

game.ReplicatedStorage.googoogaga.OnServerEvent:Connect(function(player)
	for _, v in pairs(Players:GetPlayers()) do
        v.Character:PivotTo(CFrame.new(223.612, 12.68, 22.188))
    end)
end)

this should be the new serverscript

it seems that they are already moving them on the server but using a remotevent to talk to the localscript which listens to when the prompt is triggered. however, this is possibly unneeded and can be handled entirely on the server

Good good , but it makes the player stuck on the floor lmao

oh, perhaps you should make them teleport a bit higher than the floor then haha
glad I could help!

1 Like