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

i want this to give a leaderstat when a part touches another part?

Asked by
Xeo_n 0
6 years ago

its ment to add +1 to score

script.Parent.Touched:connect(function(hit) if hit.Parent.Name == "RedCube" or "BlueCube" then Player.leaderstats.Score.Value = Player.leaderstats.Score.Value + 1 end end)

1 answer

Log in to vote
0
Answered by
Corexty 15
6 years ago

Seems like you're new to lua, so in ServerScriptService make a script;

game.Players.PlayerAdded:connect(function(plr) -- when the player joins the game
    local leaderstats=Instance.new("Configuration") --make folder of leaderstats
    leaderstats.Name="leaderstats" --define the name
    leaderstats.Parent=plr -- sets the leaderstats in the player

    local score=Instance.new("NumberValue") --makes the score value
    score.Name="Score" -- the name
    score.Parent=leaderstats --sets it so you can see the score on the leaderboard
end)

And in the part in the workspace, put the script;

script.Parent.Touched:connect(function(hit)  -- when something touches the part
    if hit.Name=="Left Leg" or "Right Leg" then --if its the leg of the player
        local Player=game.Players:GetPlayerFromCharacter(hit.Parent) -- find the player (using the character)
        Player.leaderstats.Score.Value = Player.leaderstats.Score.Value + 1 -- adds the point
    end 
end)

Thanks!

0
So, only R6 support, not R15 support? Rawblocky 217 — 6y
Ad

Answer this question