Need help with Touch event

So I’m writing a script that teleports you when you touch a part and have a certain amount of rebirths, but it doesn’t work, I’ve tried googling the problem and changed the code multiple times but nothing worked.


local Destination = game.Workspace.TPs.TP1

local function Check(leaderstats, HumanoidRootPart)
	local Rebirths = leaderstats:FindFirstChild("Rebirths")
	if Rebirths.Value >= 1000000 then
		HumanoidRootPart.CFrame = Destination.CFrame

	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	if not Humanoid then
		-- ignore
	elseif Humanoid then
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local leaderstats = Player:FindFirstChild("leaderstats")
		if leaderstats then
			print("Leaderstats found")

Edit: No error appears in the output

1 Like

What are the things it prints since you have some print statements?

1 Like

does it print “Leaderstats found”? if so, try printing the value of Rebirths. if not, make sure this script is enabled and isn’t a local script

and if you end up printing the value of Rebirths and it’s unchanged compared to the default, you’re probably changing the value only on clientside


It prints “Leaderstats found”, I haven’t tried printing the value of rebirths, I’ll try that, the script is enabled and not local

Edit: It keeps printing 0, even if I have 1M or 10M rebirths

I printed the player to see if it gets the player or if its nil and it prints “Leaderstats found” if the script finds the leaderstats

Is this a LocalScript or a ServerScript?


I have replicated the thing you want to do there and it worked perfectly fine for me.
So what could be wrong is something inside your leaderstats setup script for example something got a typo or the leaderstats folder did not get parented to the player?

1 Like

make sure you’re setting the rebirths on serverside
setting it in studio using the properties window is clientside unless you manually click the button in the test tab to swap to serverside

1 Like

Well, are your rebirths above 1000000?

1 Like

Yeah the script is Server side, the leaderstats script is in ServerScriptService, and the script that teleports you is parented to a part.

There were no typos, and the leaderstats is parented to the player.

I tried it, still didn’t work, it keeps printing “0”, even if I have 1,000,000 rebirths.

Yeah my rebirths are above a 1000000, it still keeps printing the value of rebirths as 0 though.

Which way are you adding the rebirths. The reason why its printing “0” is because you probably added them via clientside.


It worked! I looked at the script that gave the rebirths and it was a local script, I just made a remote event and now rebirths are server side.

Thank you all so much!

1 Like

That’s where RemoteEvents come into play.

1 Like