Can you SetAttributes to be reduced by a DataStore2?

  1. What do you want to achieve?
    Reduce an Attribute value by a data store.

  2. What is the issue?
    I tried a few things and figured I’d ask for help. Not sure if I can convert it to an int or something.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

function funMod.DealDmg(localPlayer)
	local boss = game.StarterGui.ScreenGui.Monster
	local healthAtt = boss:GetAttribute("Health")
	local DamageStore = DataStore2("Damage", localPlayer)
	
       --I need some logic, like healthAtt(toInt32) - DamageStore

	boss:SetAttribute("Health", healthAtt - DamageStore) -- Doesn't work sadly.
end

You need tonumber() and tostring() to convert back and forth between numbers and strings. Sometimes it will be done automatically, like if you use the concat operator ..

local Damage = DamageStore:Get()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.