I have a door script where whenever a player with the right amount of money (rc) touches the door it allows them to pass through. The code works when I tested it but it keeps telling me in output [11:12:16.443 - Workspace.Map.Map1.Doors.Door1.Script:12: attempt to index number with ‘Value’]. I know this has something to do with the fact my script has rc.Value while rc is a number, but I dont know how to fix this. Every time I try it just ruins the code. Can someone help me with this?
local rc = 500
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Cash.Value >= rc then
if debounce then
debounce = false
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
if rc.Value <= rc then
script.Parent.Transparency = 0.3
script.Parent.CanCollide = true
end
end
end
end
end)
I was following a tutorial and thats what they did. That part is supposed to make it where if you don’t have 500+ coins it wont let you pass through the door.
Use this code exactly. Just delete all your code and use this
local rc = 500
local debounce = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Cash.Value >= rc then
if debounce then
debounce = false
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
end
else
script.Parent.Transparency = 0.3
script.Parent.CanCollide = true
end
end
end)
Wait nvm, I just had a friend test it for me on Roblox. It did work. For some reason It lets me pass maybe because it added up the value of my other weight plus my 300 dollars to make 500. Thank you for taking so much time to help.