Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Snow Plower rewarding points is not rewarding?

Asked by 5 years ago

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!

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. CosmicIsGod 139 — 5y
0
Ok, I'll try. BabyBearPowStuff 11 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
Hmm, says Workspace.Basic Truck.PLOW PART.Script:3: attempt to index local 'stats' (a nil value) BabyBearPowStuff 11 — 5y
0
On line 3 BabyBearPowStuff 11 — 5y
Ad

Answer this question