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

How do I use a leaderstat value for a shop?

Asked by 3 years ago
Edited 3 years ago

Hey!! I am trying to make an old style shop where you walk into a part and if you have enough "Cash" then you can go past, if not, nothing happens. Here is my local script in the part

`local leaderstarts = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Cash") local part = script.Parent local function OnTouch(part) if leaderstarts.Value >= 10 then script.Parent.Transparency = 1 script.Parent.CanCollide = false print("Your not poor") else print("Wow your poor") end

end`

0
Also how do I make this look like script so that you can see exactly what I wrote? austenman123 2 — 3y

1 answer

Log in to vote
0
Answered by
TechModel 118
3 years ago
Edited 3 years ago

Locals scripts don't work when it is in a part on workspace I think. What I've done here is you put the part that you want to walk through and put it in ReplicatedStorage. Create a local script and put it in StarterGui.

01local leaderstarts = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Cash")
02local part = game.ReplicatedStorage.Part -- Gets the part from replicated
03local clone = part:Clone() -- Clones all individial local parts to each player
04 
05clone.Parent = workspace
06db = false
07 
08clone.Touched:Connect(function(hit)
09    if hit.Parent:FindFirstChild("Humanoid") then
10        if db == false then
11            db = true
12 
13            local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
14 
15        if plr.leaderstats.Cash.Value >= 10 then
View all 28 lines...

See if that works. Also, what is happening is cloning the part in the ReplicatedStorage and clones to players individually which only makes the part transparent locally.

Ad

Answer this question