Value doesnt change for server

i have 2 RemoteEvents to change id inside the player and to teleport a player with the id
the problem is change event changes value only for player
how do i make the changes server-sided?

Change fire event server script

game.ReplicatedStorage.Changing.OnServerEvent:Connect(function(plr, id)
	
	local tpvalue = plr:WaitForChild('ID')
	tpvalue = id
	wait(1)
	print(tpvalue) --shows the right id
end)

teleport fire event server script

game.ReplicatedStorage.TPEvent.OnServerEvent:Connect(function(plr, Id)
	local TeleportService = game:GetService("TeleportService")
	local id = plr.ID.Value
	
	print(id) -- shows me the wrong ID,
	

	TeleportService:TeleportAsync(id, {plr})
end)
1 Like
tpvalue.Value = id

That would be the first thing I’d check.
Second I would probably make variables for those Events:

local ChangingEvent = game.ReplicatedStorage:WaitForChild("Changing")

ChangingEvent.OnServerEvent:Connect(function(plr, Id)
	local tpvalue = plr:WaitForChild('ID')
	tpvalue.Value = id
	wait(1)
	print(tpvalue) --shows the right id
end)

You can try to do this.

1 Like

thanks, when i will have some spare time i will try this

2 Likes

it seems like it finally works now
Thanks!

2 Likes

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