SurfaceGui button wont work?

Hello , im trying to make a button that will teleport you to a certain gameid (value)
the problem is that when the button is pressed it wont work and no print outputs? .

here is the local script for the button

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportEvent = ReplicatedStorage:WaitForChild("Teleport")
local gameid = script.Parent.Parent.Parent.Gameid.Value


local function id()
	print("Pressed")
	print(gameid)
	TeleportEvent:FireServer(gameid) 
end


script.Parent.MouseButton1Click:Connect(id)

as you can see that i have a remote event called teleport

this is the serverscriptservice side

local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportEvent = ReplicatedStorage:WaitForChild("Teleport")

TeleportEvent.OnServerEvent:Connect(function(placeId,player)
	TeleportService:Teleport(placeId, player)
	print("player teleported to"..placeId )
end)

Thanks in advance .

Make third party teleporting enabled.

did enable it but for some odd reason the button work , and im not even getting the print outputs

hi,

judging by the face that you’re using :FireServer, i assume this is a localscript. i’m pretty sure that localscripts don’t run in the workspace by default.



Should it be
:Connect(function(player,placeId)
Correct me if im wrong

ahahaaha , the local script was the problem i changed it to a script and it worked thanks

thanks for taking your time to reply to this , but i fixed it right after i posted this post when i was trying to figure it out

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.