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`
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.
01 | local leaderstarts = game.Players.LocalPlayer:WaitForChild( "leaderstats" ):WaitForChild( "Cash" ) |
02 | local part = game.ReplicatedStorage.Part -- Gets the part from replicated |
03 | local clone = part:Clone() -- Clones all individial local parts to each player |
04 |
05 | clone.Parent = workspace |
06 | db = false |
07 |
08 | clone.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 |
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.