How do I make a teleporter depending on leaderstats?

Photo for clarification:

Screenshot_3

So I have this game with dimensions, How do I make it so if you have for instance 14 “stickmen” in the leader stats, then you can be able to touch a specific part and teleport to a place?

(Basically, you can only teleport to this place by touching a part and it will only teleport you if you have for example 14 stickmen)

You would use a touched function, and :GetPlayerFromCharacter().

local part = -- part

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr and plr.leaderstats.Stickmen.Value >= 14 then
		--teleport
	end
end)
1 Like

Thank you!

I apologize for asking as I’m a bad scripter, but I was wondering where do I put the ID of the place the player will teleport to if they have the required leader stats value?

Oh, you would have the player as the second parameter and the place id as the first. ex:

local part = -- part
local TPS = game:GetService("TeleportService")
local placeid = 00000--place id

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr and plr.leaderstats.Stickmen.Value >= 14 then
		TPS:Teleport(placeid, plr)
	end
end)
2 Likes

Thank you so much you’re extremely helpful!!

1 Like