Teleportation button is not teleporting

So I’m trying to make a system that teleports players to cubicles. The problem is, there is no teleportation both clientside and serverside. the video and the scripts will be attached down there
video:

Serverside view of the player, taken after vid

Button’s script

local button = script.Parent
local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage.playerTeleport

button.MouseButton1Click:Connect(function()
	event:FireServer()
end)

Teleportation Script

local players = game.Players:GetChildren()
local rs = game:GetService("ReplicatedStorage")
local tpEvent = rs.playerTeleport
local V3s = require(rs.RoundV3s)

tpEvent.OnServerEvent:Connect(function()
	for cubicle, player in pairs(players) do
		local plrChar = player.Character
		local HRP = plrChar:FindFirstChild("HumanoidRootPart")
		HRP.Position = V3s[cubicle]
	end	
end)

The ModuleScript with the Vector3 value table

local roundV3s = {}

roundV3s.V3s = {
	Vector3.new(105.656, 1540.594, 0),
	Vector3.new(105.656, 1540.594, 70.875),
	Vector3.new(105.656, 1540.594, 35.438),
	Vector3.new(35.437, 1540.594, 105.656),
	Vector3.new(70.875, 1540.594, 105.656),
	Vector3.new(105.656, 1540.594, -70.875),
	Vector3.new(105.656, 1540.594, -35.437),
	Vector3.new(-105.656, 1540.594, -35.438),
	Vector3.new(0, 1540.594, 105.656),
	Vector3.new(-35.438, 1540.594, 105.656),
	Vector3.new(-35.437, 1540.594, -105.656),
	Vector3.new(0, 1540.594, -105.656),
	Vector3.new(-105.656, 1540.594, 35.437),
	Vector3.new(-70.875, 1540.594, -105.656),
	Vector3.new(35.438, 1540.594, -105.656),
	Vector3.new(70.875, 1540.594, -105.656),
	Vector3.new(-105.656, 1540.594, -70.875),
	Vector3.new(-105.656, 1540.594, 0),
	Vector3.new(-105.656, 1540.594, 70.875),
	Vector3.new(-70.875, 1540.594, 105.656)
 }

return roundV3s
1 Like

You should call “GetPlayers” function when you actually process the event, not before the event which probably returns an empty table at that time.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local tpEvent = rs.playerTeleport
local V3s = require(rs.RoundV3s)

tpEvent.OnServerEvent:Connect(function()
    local players = Players:GetPlayers()

	for cubicle, player in players do
		local plrChar = player.Character
		local HRP = plrChar:FindFirstChild("HumanoidRootPart")
		HRP.Position = V3s[cubicle]
	end
end)
1 Like

hey thanks it worked, I just realized I forgot the list from the module but it was an easy fix. Thanks anyway.

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