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

Snow Plower rewarding points is not rewarding?

I am trying to make a snow plowing job in my game, and when you plow a part off, you get a SnowPoint in the leaderstats. I am a scripter who learns on very little, and because of that, I need some help. I took a vehicle from workspace and welded a part on the vehicle, named "PLOW PART" . This part is the part that 'plows' the snow. There is another part called "Snow", which is the part that is plowed. Here is the working script for the plow part when I didn't add the SnowPoint for them (The snow part does not have a script) :

PLOW PART script:

function onTouch(hit)
	if hit.Name == "Snow" then
	hit.Transparency = 1
	wait(10)
	hit.Transparency = 0
end

end


script.Parent.Touched:connect(onTouch)

The script 'plows' the things named "Snow". Though, with the edited version that is supposed to give you the SnowPoint just does not give the SnowPoint and doesn't make the "PLOW PART" even 'plow' the snow. I put in "--added" so you can figure out what was edited from the original.

PLOW PART script:

	local user = game.Players--added
	local stats = user:findFirstChild("leaderstats")--added
	local SnowPoint = stats:findFirstChild("SnowPoint")--added
	
function onTouch(hit)
	if hit.Name == "Snow" then
	hit.Transparency = 1
	wait(10)
	hit.Transparency = 0
	SnowPoint.Value  = SnowPoint.Value +10--added
end

end


script.Parent.Touched:connect(onTouch)

And here, so you don't have to do any more scripting, is the leaderstats that i set up, the "PLOW PART", and vehicle:

NOT WORKING PLOWER (edited one) : https://www.roblox.com/library/4484861101/Not-working-Plower

WORKING PLOWER (original): https://www.roblox.com/library/4484936565/Original-snow-plower

I know i was a bit confusing, so please feel free to ask any questions, and thanks!

2 comments

0

well um for starters if you didn't use variables to do whatever the colon things are it would say local stats = game.Players:FindFirstChild("leaderstats") so u need to get the local player to access leaderstats. So to fix this A. Use remote events (your server script can't access local player) or B. maybe get the local player by finding the parent of the tool (backpack) and the player from there.

0

Ok, I'll try.

1 answer

✓ Accepted answer

Now tell me exactly where this script is but from looking at the script I think I know where so try this:

local user = script.Parent.Parent.Parent.Parent -- First Parent Plow Part, Second Tool, Third Backpack, and Finally Player
    local stats = user:FindFirstChild("leaderstats")--added
    local SnowPoint = stats:FindFirstChild("SnowPoint")--added

function onTouch(hit)
    if hit.Name == "Snow" then
    hit.Transparency = 1
    wait(10)
    hit.Transparency = 0
    SnowPoint.Value  = SnowPoint.Value +10--added
end

end


script.Parent.Touched:connect(onTouch)

2 comments

0

Hmm, says Workspace.Basic Truck.PLOW PART.Script:3: attempt to index local 'stats' (a nil value)

0

On line 3

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