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

Problem with this script can u also put a finished product?

local Part = script.Parent Part.Touched:Connect(function(HIT) local H = HIT.Parent:FindFirstChild("Humanoid") if H then local player = game.Players:GetPlayerFromCharacter(HIT.Parent) if player then local leaderstats = player:WaitForChild("leaderstats") local Currency = leaderstats.Cash local Selling = leaderstats.Strength if Selling.Value > 0 then Currency.Value = Currency.Value + Selling.Value *1 Selling.Value = 0 end end end end)

Also it said this in the output, 11:19:37.285 - Cash is not a valid member of Folder, and this is an attempt on a sell cash script

1 comment

0

What is a developer product anyone?

1 answer

Use WaitForChild on the stat too, because it takes time for it to load also.

 local Part = script.Parent 

Part.Touched:Connect(function(HIT) 
local H = HIT.Parent:FindFirstChild("Humanoid")
 if H then

 local player = game.Players:GetPlayerFromCharacter(HIT.Parent)
if player then 

local leaderstats = player:WaitForChild("leaderstats") 
local Currency = leaderstats:WaitForChild("Cash")
local Selling = leaderstats:WaitForChild("Strength")

if Selling.Value > 0 then 
Currency.Value = Currency.Value + Selling.Value * 1
Selling.Value = 0
end 
end 
end 
end)

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