✓ Accepted answer
I think this will work:
Leaderboard script (ServerScriptService)
game:GetService("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Parent = leaderstats
points.Value =0
end)
Teleport script (Part)
local POINTS_NEEDED_TO_TELEPORT = 14
local TeleportPart = workspace.Teleport
local function teleport(character, part)
character.HumanoidRootPart.CFrame = part.CFrame + Vector3.new(0,5,0)
end
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local points = leaderstats:FindFirstChild("Points")
if points then
if points.Value >= POINTS_NEEDED_TO_TELEPORT then
teleport(hit.Parent, TeleportPart)
end
else
warn(tostring(player), "does not have points!")
end
else
warn(tostring(player),"does not have leaderstats!")
end
end
end
end)
Tell me if it doesn't work.
1 comment
I'll try it and let you know, thank you so much!