I'm making a stat system, and in the script below, I have an attack that damage multiplies by the stats value. During testing, however, it only multiplied it by the default amount (1). In other words, when I updated my stats, it didn't multiply by the updated stat. It works, as I set it to a higher number and it multiplied, but it wouldn't update if the value was updated.

game.ReplicatedStorage.Events.Skill1.OnServerEvent:Connect(function(player, mousePos)
	local effects = game.ReplicatedStorage.Effects
	local fireBall = effects.MagicSkill:Clone()
	local explosion = effects.Explosion:Clone()
	local character = player.Character
	local StrVal = player.StatFolder.Str.Value
	--Fireball--
	fireBall.Position = character.RightHand.Position
	fireBall.Parent = workspace
	
	--Weld--
	local weld = Instance.new("WeldConstraint", fireBall)
	weld.Part0 = fireBall
	weld.Part1 = character.RightHand
	wait(0.1)
	weld:Destroy()
	
	local velocity = Instance.new("BodyVelocity", fireBall)
	velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100
	
	--Explosion--
	fireBall.Touched:Connect(function(hit)
		if hit:IsDescendantOf(character)or hit:FindFirstChild("ParticleEmitter") then return end
		explosion.Position = fireBall.Position
		fireBall:Destroy()
		explosion.Parent = workspace
		
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent:FindFirstChild("Humanoid"):TakeDamage(30 * StrVal) --Where I tried to multiply it

		end
		wait(5)
		explosion:Destroy() 
	end)
end)

3 comments

0

try updating the strval every time it does a takedamage event (strval = player.StatFolder.Str.Value)

0

alr, ill try it right now.

0

still doing damage, but its not multiplying still.