Okay, you've got a few things wrong here.
First of all, the local place and local spawn will only work if there is something in the Script, such as a value.
Also, you have set two variables to nil values. You should remove local placeId and local spawnName from the script altogether, because those would screw things up.
I'm not sure what the Teleport event tag is, but I'm not sure if :TeleportToSpawnByName is correct, so you should probably check that.
And remove spawn.Value from the 9th line, all you need is if spawn then.
Lastly, you need a function and a connection line. And make sure that there is a Click Detector in the brick you want.
Here's the edited code:
function onClick()
local place = script:FindFirstChild("PlaceId")
local spawn = script:FindFirstChild("DestinationSpawnName")
if place then
placeId = place.Value
if spawn then
spawnName = spawn.Value
game:GetService("TeleportService"):TeleportToSpawnByName(placeId, spawnName)
else
game:GetService("TeleportService"):Teleport(placeId)
end
end
script.Parent.MouseButton1Down:connect(onClick)
If that doesn't work, let me know. Check your output when you run the script.
1 comment
function onClicked() at the top it gives a error