Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I edit this server to client function to access the localplayer?

I need to make it so when you step on a part you get teleported to a lobby, which I already have down. It's just that the "plrservice.PlayerAdded" part keeps track of the latest player added, and not the local player. How could I edit this to fire to the Localplayer's client, not some random person who joined after you?
plrservice.PlayerAdded:Connect(function(plr)
	part1.Touched:Connect(function(hit)
		if hit.Parent:WaitForChild("Humanoid") then
			if debounce then
				debounce = false
				wait(0.8)
				ev1:FireClient(plr)
				wait(1)
				debounce = true
			end
		end
	end)
end)

1 comment

0

why would you need the localplayer? you can get the player instance in other ways

1 answer

✓ Accepted answer

You can check if the player who touched the part is you.

plrservice.PlayerAdded:Connect(function(plr)
	part1.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChildOfClass("Humanoid") and (plrservice:GetPlayerFromCharacter(hit.Parent) == plr) then
			if debounce then
				debounce = false
				task.wait(0.8)
				ev1:FireClient(plr)
				task.wait(1)
				debounce = true
			end
		end
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.