Script error: Rendering first line

local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

script.Parent.Touched:Connect(function(Hit)
if Hit.Name == “Part” and Hit:FindFirstChild(“CashValue”) then
CashValue.Value += Hit:FindFirstChild(“CashValue”).Value
Hit:Destroy()
end
end)

All I can say is make sure you have referenced your values properly.

I have adjusted your current script and this should fix the problem:

local Part = script.Parent

Part.Touched:Connect(function(OtherPart)
   local Player = game.Players:GetPlayerFromCharacter(OtherPart.Parent)

   if Player then
      Player.leaderstats.Cash.Value += 10 -- Amount you are rewarding player

      Part:Destroy()
   end
end)
1 Like

That’s not that problem. I have that already in my other script: --//Variables
local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

–//Loops
while task.wait(2) do
local newPart = Instance.new(“Part”)
newPart.Position = script.Parent.SpawnPart.Position
newPart.Size = Vector3.one
newPart.BrickColor = BrickColor.new(“Dusty Rose”)
newPart.Material = (“Marble”)

local newEmitter = Instance.new("ParticleEmitter")
newEmitter.Color = ColorSequence.new(BrickColor.new("Dusty Rose").Color)
newEmitter.Size = NumberSequence.new(1) --//Put whatever number you want
newEmitter.Parent = newPart
newEmitter.TimeScale = (0.2)

local CashValue = Instance.new("NumberValue")
CashValue.Value = 1
CashValue.Name = "CashValue"
CashValue.Parent = newPart

newPart.Parent = DropperPartsFolder

end

It says something is wrong with the first line:
local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

From my understanding you could have referenced it incorrectly?

Can you show me where this ‘CashValue’ stored as I may be able to help?

the leader stats. That is where the cash value is.

The Cash is on the leaderboard. And I added Value.

Ok so, if ‘CashValue’ is an IntValue or NumberValue inside of your ‘leaderstats’ folder, you can write this as I have displayed in my first post:

Player.leaderstats.CashValue.Value += 10 -- Amount you want to reward player with

Hope this helps.

This is the dropper, this drops a part. A conveyor transfers it in the part.

This is the code from the dropper:
–//Variables
local DropperPartsFolder = script.Parent.Parent.Parent.DropperParts

–//Loops
while task.wait(2) do
local newPart = Instance.new(“Part”)
newPart.Position = script.Parent.SpawnPart.Position
newPart.Size = Vector3.one
newPart.BrickColor = BrickColor.new(“Dusty Rose”)
newPart.Material = (“Marble”)

local newEmitter = Instance.new("ParticleEmitter")
newEmitter.Color = ColorSequence.new(BrickColor.new("Dusty Rose").Color)
newEmitter.Size = NumberSequence.new(1) --//Put whatever number you want
newEmitter.Parent = newPart
newEmitter.TimeScale = (0.2)

local CashValue = Instance.new("NumberValue")
CashValue.Value = 1
CashValue.Name = "CashValue"
CashValue.Parent = newPart

newPart.Parent = DropperPartsFolder

end

– newPart.Material = (“Marble”)

all of my games scripts are now broken except the leader stats.

roblox is so stupid. i lost my scripts some how!