I have the following localscript inside a follow friend button

local res = script.Parent.Parent:WaitForChild("result")
local foll= script.Parent.Parent.PName
local id
local teleportService = game:GetService("TeleportService")


script.Parent.MouseButton1Down:connect(function()
	if deb then
		deb = false
		id = game.ReplicatedFirst.FollowFriend:InvokeServer(foll.Text)
		if (id) then
			teleportService:TeleportToPlaceInstance(570934982, id, p)
		else
		res.Text = "Could not teleport: server might be full or player is not playing"
		wait(.2)
		deb = true
		end
	end
end)

which calls this remote function inside a server script

local event = game.ReplicatedFirst.FollowFriend
players = game.Players
local teleportService = game:GetService("TeleportService")

function event.OnServerInvoke(player,following)
	local id = players:GetUserIdFromNameAsync(following)
	if id and id>0 then
		local success, errorMsg, placeId, instanceId = teleportService:GetPlayerPlaceInstanceAsync(id)
	    if success and (570934982==placeId) then
			return instanceId
	    else
	        return false
	    end
	else
		return false
	end
end

When I test it offline I get "GetPlayerInstanceAsync" needs to be called from the server, when I test it online, the code does not run, no matter what I do the code inside the remote function does not work. I tried adding some print("stuff") to see where it breaks but those don't run either. Any idea what's wrong?

2 comments

0

I tried testing the script with and without FilteringEnabled, it didin't work either way

0

I think you have to teleport from the server