I did not know exactly what to title this, but here is my problem:
I have a proximity prompt that when fired, it will teleport the player to a certain position, but the player is only teleported on the client.
The strange thing is, that this is in a serverscript, not a localscript. I have tried different things such as firing a bindable event to another serverscript to teleport, but that still only moved the player on the client. Then I tried making a localscript that fires a remote event and the server moves the player, and it still only did it for the client.
Why is this happening?
My current script (local that fires to server):
local enter = game.Workspace.Bunker.BunkerEntrance.PrimaryPart.EnterBunker
enter.Triggered:Connect(function(plr)
if plr == game.Players.LocalPlayer then
if plr.Character then
if plr.Character.Humanoid.Health > 0 then
game.ReplicatedStorage.Events.BunkerTP:FireServer(true)
end
end
end
end)
local leave = game.Workspace.Bunker.BunkerLeaveHatch.PrimaryPart.ExitBunker
leave.Triggered:Connect(function(plr)
if plr == game.Players.LocalPlayer then
if plr.Character then
if plr.Character.Humanoid.Health > 0 then
game.ReplicatedStorage.Events.BunkerTP:FireServer(false)
end
end
end
end)
local function OnTP(player, enter)
if player.Character then
if enter then
player.Character.HumanoidRootPart.Position = game.Workspace.BunkerTP.Position
else
player.Character.HumanoidRootPart.Position = game.Workspace.BunkerLeave.Position
end
end
end
game.ReplicatedStorage.Events.BunkerTP.OnServerEvent:Connect(OnTP)
local function OnTP(player, enter)
if player.Character then
if enter then
player.Character:MoveTo(game.Workspace.BunkerTP.Position)
else
player.Character:MoveTo(game.Workspace.BunkerLeave.Position)
end
end
end
game.ReplicatedStorage.Events.BunkerTP.OnServerEvent:Connect(OnTP)