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

Why wont it give cash?? what's wrong here?

Title says it all... Here's the script:

script.Parent.Touched:connect(function(hit)
	humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid ~= nil then
		hit.Parent.leaderstats.Cash.Value = hit.Parent.leaderstats.Cash.Value +script.Parent.Cash.Value
		script.Parent.Cash.Value = 0
	end
end)

Output: 20:26:36.266 - leaderstats is not a valid member of Model 20:26:36.268 - Script 'Workspace.Model.ToCollect.Script', Line 4 20:26:36.269 - Stack End 20:26:36.270 - Disconnected event because of exception

1 answer

Btw this is not tested.

What this would I hope do is give cash if the cash value is inside leaderstats and i hope you inserted leaderstats into the player and it will double the cash and if you wanna change the cash recieved or taken there is a comment there

and then will wait 5 seconds before repeating process

local db = true
local coolingtime = 5
script.Parent.Touched:connect(function(hit)
	if not db then return end	
	local human = hit.Parent:findFirstChild("Humanoid")
	if human then
	db = false
	local cash = game.Players:GetPlayerFromCharacter(hit.Parent).leaderstats.Cash
	cash.Value = cash.Value + cash.Value --change here to change cash given
        wait(coolingtime)
    end
end)

1 comment

0

Naa, Wrong thing. It's not continuous every 5 seconds. Its when a player touches a brick, the brick has a value, That value adds to the leaderstat AND that value get reset to 0. and Yes, there is a "Cash" IntValue in "leaderstats"

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