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

Is GiveExp to dummy when killed script good done?

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

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)

2 comments

0

This will not work. Because the dummy have to be killed so the player can get the EXP. Let me answer this question.

0

well maybe he wants it so that whenever he hits the dummy, player gets exp.

The answer will be in 40min

I'm answering other questions.

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