#Tp script is doing nothing

1 messages · Page 1 of 1 (latest)

brazen forge
#

it so post to Tp all players in 5 sec to a part name Spawn in a folder that will be random in a folder called MapAtPlay in workspaces, instead it does nothing, and no errors are apearing in the feedback and there is a ClickDetector in the part taht is being clicked, there also other script in that same part but, i dont think it should effect it
thanks for any who trys to help

#
clickDetector.Parent = script.Parent

local Players = game:GetService("Players")
local MapAtPlay = workspace:WaitForChild("MapAtPlay")

clickDetector.MouseClick:Connect(function(playerWhoClicked)
    print("Clicked by", playerWhoClicked.Name)
    wait(5)  -- wait 5 seconds before teleporting

    -- Find all folders inside MapAtPlay
    local folders = {}
    for _, child in pairs(MapAtPlay:GetChildren()) do
        if child:IsA("Folder") then
            table.insert(folders, child)
        end
    end

    print("Found folders inside MapAtPlay:", #folders)
    if #folders ~= 1 then
        warn("Expected exactly one folder inside MapAtPlay, found " .. #folders)
        return
    end

    local randomFolder = folders[1]
    print("Random folder found:", randomFolder.Name)

    local spawnPart = randomFolder:FindFirstChild("Spawn")
    if not spawnPart then
        warn("Spawn part NOT found inside folder:", randomFolder.Name)
        return
    end

    print("Spawn part found:", spawnPart:GetFullName())

    if not spawnPart:IsA("BasePart") then
        warn("Spawn is not a BasePart! Found type:", spawnPart.ClassName)
        return
    end

    for _, player in pairs(Players:GetPlayers()) do
        local character = player.Character
        if character then
            local hrp = character:FindFirstChild("HumanoidRootPart")
            if hrp then
                print("Teleporting", player.Name)
                hrp.CFrame = spawnPart.CFrame + Vector3.new(0, 3, 0)
            else
                warn(player.Name .. "'s character has no HumanoidRootPart")
            end
        else
            warn(player.Name .. " has no character")
        end
    end
end)
#

i forgot how to format it

drifting grail
#

Enclose the code within three backticks. I just guessing, sorry

brazen forge
#

thank you for trying

gloomy elm
brazen forge
gloomy elm
#

Don't enter the lua, it belong the same row, like in picture,

Your problem, Does any of warn/print debug?

brazen forge
#

beside the other error that are coming from other scripts

worthy smelt
#

5 people telling ts guy to format but no one giving him any advice🥀

#

is this the parent of the script a Part?

hushed basin
worthy smelt
hushed basin
#

I aint opening roblox studio just to read smn code

#

it takes to long for open it

worthy smelt
#

idk i have it always open

hushed basin
#

@brazen forge the issue is that

clickDetector.MouseClick:Connect(function(playerWhoClicked)

works only on client

#

You gotta create local script in StarterPlayerScripts

#

where you detect mouse click

#

then fire remote event to activate script on server

hushed basin
#

nvm

#

Forgot

#

It's possible that roblox studio got some problem currently, it sometimes happens

#

or there is other issue

brazen forge
drifting grail
#

What MaxActivationDistance of that ClickDetector?

polar hatch
brazen forge
brazen forge
hushed basin
#

Yes i did

#

🔥