Ad
Log in to vote
2

Broken Spawning script?

Asked by 7 years ago
local SpawnPoints = {Vector3.new(150.9, 13.9, -65.9),Vector3.new(141.7, 42.9, 22.5), Vector3.new(-38.3, 37.3, -119.7), Vector3.new(-72.3, 6.9, -159.5), Vector3.new(141.9, 5.5, -128.3), Vector3.new(172.1, 6.3, 60.9), Vector3.new(-64.3, 5.7, 56.1), Vector3.new(-32.5, 5.1, 17.9), Vector3.new(-65.7, 5.1, -82.5), Vector3.new(107.9, 29.1, -109.3), Vector3.new(78.5, 5.7, 54.5), Vector3.new(21.1, 5.3, -144.5)}

function teleportrandom()
wait()
script.Parent.Parent:MoveTo(SpawnPoints[math.random(1,#SpawnPoints)])

It won't work and I tried Players.Character and THAT only works in the Testing not the actually ROBLOX server... I am really lost right now.

2 answers

Log in to vote
3
Answered by 7 years ago

1) There is no end statement for your function 2) Put it in a Localscript, then use at line 5:

game.Players.LocalPlayer.Character:MoveTo(SpawnPoints[math.random(1,#SpawnPoints)])
0
It would be game.Players.LocalPlayer.Character Thewsomeguy 448 — 7y
0
Oh sorry, editing Hippalectryon 3 — 7y
Ad
Log in to vote
0
Answered by
adark 5472 Badge of Merit Moderation Voter Community Moderator
7 years ago

Two questions: 1) Is this a local script? 2) Where, exactly, is this script located?

I ask the first, because if this is all of the code (which it obviously isn't, but whatever), you will be able to make this a local script without anything breaking, which may solve your problem. If it already is a local script, making it a script could also fix it.

I ask the second for more context if what I said above doesn't work.

What you can try is teleporting by setting the Torso's CFrame rather than calling MoveTo() on the Character's Model. I find that MoveTo() is unreliable for some reason whenever I try to use it for teleportation.

Answer this question