Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

coins to enter door script not working? help needed

so im trying to make a simple door part where if the player touches and doesn't have enough coins, they can't enter whilst if they have enough coins, they can go through

local Door = script.Parent
local player = game.Players.LocalPlayer

---

Door.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if player:WaitForChild("leaderstats"):FindFirstChild("Coins").Value > 3 then
	print("u have enough coins")
	Door.Transparency = 0.8
	Door.CanCollide = false
elseif player:WaitForChild("leaderstats"):FindFirstChild("Coins").Value < 3 then
	print("u dont have enough coins")
	Door.Transparency = 0
	Door.CanCollide = true
end
end
end)

but it keeps showing up as an error and i cant seem to fix it. ive tried setting

player:WaitForChild("leaderstats"):FindFirstChild("Coins") = local Coins

but it still doesnt work. anyone can help?

1 comment

0

What's the error

1 answer

local Door = workspace.Part
local player = game.Players.LocalPlayer

---

Door.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if player:FindFirstChild("leaderstats"):FindFirstChild("Coins").Value >= 3 then
    print("u have enough coins")
    Door.Transparency = 0.8
    Door.CanCollide = false
elseif player:FindFirstChild("leaderstats"):FindFirstChild("Coins").Value < 3 then
    print("u dont have enough coins")
    Door.Transparency = 0
    Door.CanCollide = true
end
end
end)

This script works for me. Put it in StarterCharacterScripts.

1 comment

0

thanks! if i could upvote i would.

This discussion is preserved as it was. New answers, comments, and votes are closed.