when i add points in defense or speed my walkspeed and maxhealth don't change, i need help
This is my script
local spdPerPoint = 2
local staterSpeed = 16
local dfPerPoint = 10
game.Players.PlayerAdded:Connect(function(player)
local attr = Instance.new("Folder")
attr.Name = "Attributes"
attr.Parent = player
local defense = Instance.new("IntValue")
defense.Name = "Defense"
defense.Parent = player
local strenght = Instance.new("IntValue")
strenght.Name = "Strenght"
strenght.Parent = player
local speed = Instance.new("IntValue")
speed.Name = "Speed"
speed.Parent = player
end)
local repStorage = game:GetService("ReplicatedStorage")
local dfRemote = repStorage.Remotes.AddHealth
local spdRemote = repStorage.Remotes.AddSpeed
local strRemote = repStorage.Remotes.AddStrenght
local function PointsAvailable(player)
local PointsUsed = player.Attributes.Health.Value + player.Attributes.Strenght.Value + player.Attributes.Health.Value
local PointsAvailable = player.LevelsInfo.Level.Value - PointsUsed
return PointsAvailable > 0
end
dfRemote.OnServerEvent:Connect(function(player)
if not PointsAvailable(player) then return end
player.Attributes.Health.Value += 1
local dfPerPoint = 10
player.Character.Humanoid.MaxHealth = 100 + player.Attributes.Health.Value * dfPerPoint
player.Character.Humanoid.Health = 100 + player.Attributes.Health.Value * dfPerPoint
end)
spdRemote.OnServerEvent:Connect(function(player)
if not PointsAvailable(player) then return end
player.Attributes.Speed.Value += 1
local spdPerPoint = 2
local starterSpeed = 16
player.Character.Humanoid.WalkSpeed = starterSpeed + player.Attributes.Speed.Value * spdPerPoint
end)
strRemote.OnServerEvent:Connect(function(player)
if not PointsAvailable(player) then return end
player.Attributes.Strenght.Value += 1
end)

5 comments
Could you please attempt to put the script together so it is easier to read? It is very tricky otherwise to read.
Anyways, according to what I could read in your script, it either doesnt do anything, or, it only works once the player has bought a stat point thing, therefore not working after he dies.
can you help me with another script?
Sure.
Are you Brazilian?