Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a teleporter depending on leaderstats?

Asked by 3 years ago

So I have this game with dimensions, How do I make it so if you have for instance 14 “points” 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 points in the leader stats), how do I make that?

2 answers

Log in to vote
0
Answered by 3 years ago

I think this will work:

Leaderboard script (ServerScriptService)

01game:GetService("Players").PlayerAdded:Connect(function(player)
02    local leaderstats = Instance.new("Folder")
03    leaderstats.Name = "leaderstats"
04    leaderstats.Parent = player
05 
06 
07    local points = Instance.new("IntValue")
08    -- Name to what it's called
09    points.Name = "Points"
10    points.Parent = leaderstats
11    points.Value =0
12end)

Teleport script (Part)

01-- Points needed to teleport:
02local POINTS_NEEDED_TO_TELEPORT = 14
03 
04-- Name to the part you want to teleport to
05local TeleportPart = workspace.Teleport
06 
07local function teleport(character, part)
08    character.HumanoidRootPart.CFrame = part.CFrame + Vector3.new(0,5,0)
09end
10script.Parent.Touched:Connect(function(hit)
11    local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
12    if hum then
13        local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
14        if player then
15            local leaderstats = player:FindFirstChild("leaderstats")
View all 30 lines...

Tell me if it doesn't work.

0
I'll try it and let you know, thank you so much! Ghostinee 27 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Here's the code, hope its helping you :)

Leaderstats script :

01local plrs = game:GetService("Players")
02 
03plrs.PlayerAdded:Connect(function(p)
04 
05    local LS = Instance.new("Folder")
06    LS.Name = "leaderstats"
07    LS.Parent = p
08 
09    local Value = Instance.new("IntValue")
10    -- Change the string to anything you desired
11    Value.Name = "Value"
12    Value.Value = 0
13    Value.Parent = LS
14end)

Teleport script :

01local plrs = game:GetService("Players")
02 
03-- Change the Value of the Variable to anything you desired
04local valueneed = 1
05 
06-- Put the script into the part or change it to "workspace.(YOUR PART'S NAME)"
07local tpPart = script.Parent
08 
09-- Change this to the "endPos" to Part's name
10local endPos = workspace.endPos
11 
12function tp(char, pos)
13    char:PivotTo(char:GetPivot() * pos.CFrame)
14end
15 
View all 35 lines...

If not work, tell me.

0
... echobloxia 21 — 3y
0
I'll try it and let you know if it doesn't work, thank you so much!! Ghostinee 27 — 3y
0
btw echo, u can tell me if there's any copy of it GoldenKnightFly 0 — 3y

Answer this question