I made a teleporter script that teleports the player to one of nine random locations on the map when they touch a specific part however whenever I play the game, It doesn’t run. I put a print statement on the 1st line of the script and it didn’t even print. This has happened before and randomly fixes it’s self, But this time it won’t. I have also tried restarting studio but still nothing. The code is functional with no errors either. It’s not disabled and nothing is causing it to not work to my knowledge. The script is under a part which is under a folder in the workspace. Any ideas?
You should put your script up to be analyzed by developers.
print("hi")
local teleportPart = script.Parent
local locations = {}
for i = 1, 9 do
local locationPart = game.Workspace.Locations:FindFirstChild("Location" .. i)
if locationPart then
table.insert(locations, locationPart)
end
end
if teleportPart then
teleportPart.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local locationPart = locations[math.random(1, #locations)]
player.Character.HumanoidRootPart.CFrame = locationPart.CFrame
end
end)
end
Is the script enabled in properties? Where is the script placed in explorer?
LocalScripts do not work in workspace, change to a normal Script instead.
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.