What do you want to achieve?
I’m trying to make a door that will only let players through if they have $2,000
What is the issue?
The script isn’t working
What solutions have you tried so far?
I tried adding a print statement to the part where the part is touched but nothing printed in the output.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Plr)
local cashValue = Plr.leaderstats:WaitForChild("Cash")
script.Parent.Touched:Connect(function(Touch)
if Touch.Parent:FindFirstChild("Humanoid") ~= nil then
if cashValue.Value >= 2000 then
for i = 0, 1, -0.1 do
script.Parent.Transparency = i
wait(0.1)
end
wait(1)
for i = 1, 0, 0.1 do
script.Parent.Transparency = i
wait(0.1)
end
end
else
print("not enough")
end
end)
end)
Have you tried getting the player by who touched the part? You can use :GetPlayerFromCharacter() like so: script.Parent.Touched:Connect(function(Touch) if Touch.Parent:FindFirstChild("Humanoid") ~= nil then local plr = game:GetService("Players"):GetPlayerFromCharacter(Touch.Parent)
Edit: apologies for the improper indentation i’ll try to fix it.
local Money = game.Players.LocalPlayer.leaderstats:WaitForChild("Cash")
while true do
wait(1)
if Money.Value >= 2000 then
game.Workspace.DoorPart.CanCollide = false
game.Workspace.DoorPart.Transparency = 1
wait(1)
script:Destroy()
end
end