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

Is GiveExp to dummy when killed script good done?

Asked by 4 years ago

i want dummy to give exp but it doesnt do anything

local PlayersService = game:GetService("Players")

local function onTouch(hit)
    local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
    local expPoints = player:findFirstChild("leaderstats")
    if expPoints ~= nil then
        local points = expPoints:findFirstChild("Exp")
        if points ~= nil then
            points.Value = points.Value + 5
        end
    end
end

script.Parent.Touched:connect(onTouch)

scrypt analysis is clear

2 answers

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
4 years ago

I believe you should not have the two if statements.

local PlayersService = game:GetService("Players")

local function onTouch(hit)
    local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
    local expPoints = player:findFirstChild("leaderstats")
    local points = expPoints:findFirstChild("Exp")
    points.Value = points.Value + 5
end

script.Parent.Touched:connect(onTouch)
0
This will not work. Because the dummy have to be killed so the player can get the EXP. Let me answer this question. Foxy_Developer 111 — 4y
0
well maybe he wants it so that whenever he hits the dummy, player gets exp. bluzorro 417 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

The answer will be in 40min

I'm answering other questions.

Answer this question