Hello there! Some time ago (about a month back), I was working on a chest script with a simple concept: teleport to one of the positions and if you make contact with it, you win! However, it didn’t work as expected. I’m still in the process of refining the script to get it functioning properly. Interestingly, no error messages are being displayed on my end.
Here’s the script I have ( its the teleporting script ):
local spawns = workspace.Spawns:GetChildren()
local Chest = game.Workspace.Chest
local function onTouch(part)
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
if not humanoid then
return
end
local chest = part.Parent:FindFirstChild("ChestRandom")
if not chest then
return
end
-- Choose a random spawn position
local randomSpawnIndex = math.random(1, #spawns)
local randomSpawn = spawns[randomSpawnIndex]
local targetPosition = randomSpawn.Position
chest:MoveTo(targetPosition)
end
local triggerPart = Chest
triggerPart.Touched:Connect(onTouch)
Regarding the absence of an “end” statement, it’s because the script is designed to run indefinitely, unless someone leaves the server, which would then close the script’s execution.