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
#Tp script is doing nothing
1 messages · Page 1 of 1 (latest)
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
Enclose the code within three backticks. I just guessing, sorry
thank you for trying
oh thank you really much
Don't enter the lua, it belong the same row, like in picture,
Your problem, Does any of warn/print debug?
no
beside the other error that are coming from other scripts
5 people telling ts guy to format but no one giving him any advice🥀
is this the parent of the script a Part?
ngl its almost unreadable without formating
it takes 3 seconds to paste it into a new script in studio
idk i have it always open
@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
nvm
Forgot
It's possible that roblox studio got some problem currently, it sometimes happens
or there is other issue
Correct
What MaxActivationDistance of that ClickDetector?
this is incorrect https://create.roblox.com/docs/reference/engine/classes/ClickDetector#MouseClick
MouseClick
This event fires from either a Script or LocalScript when a player interacts with a ClickDetector
I know what you’re getting at, but that not problem because a different script is working
he did say
"nvm
Forgot"
i belive he remebered