#Leaderstats script thingy, (new to scripting)

1 messages · Page 1 of 1 (latest)

timber ibex
#

Im new to scripting and cant figure out why this script wont give the player a point, Thanks.

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local leaderstats = hit.Parent:FindFirstChild("leaderstats")
local Score = leaderstats:FindFirstChild("Score")
Score.Value = Score.Value + 1
end
end)

placid ermine
timber ibex
#

It’s a regular script

timber ibex
#

lol you mean like a local script or script?

willow hillBOT
#

studio** You are now Level 1! **studio

timber ibex
#

I’m using a script, I don’t know when to use a local script yet.

placid ermine
#

u use local script when you want to do something for only one player

#

server side it's for everyone

#

so

#

k im here

#

put a "Usual script" not local in ur part

#

and

#

something like this

#
    if Hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players[Hit.Parent.Name]
        
        Player.leaderstats.Score.Value = Player.leaderstats.Score.Value + 1
    end
end)```
#

should work

timber ibex
#

Ok thanks

#

Sorry to bother, you don’t have to answer but if it was a kill brick instead why does that have a regular script instead of local? Is it because everything sees the players death or something?

placid ermine
timber ibex
#

Ok thanks

timber ibex
#

I tried with a local script and it still didn’t work, but I think I found the real reason, I think it’s because the leaderstats folder is in my player not the character that’s touching the part.

Can you confirm this?

placid ermine
#

bro dont try do server side things on local side

placid ermine
placid ermine
#

look at the script i sent