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

Hi, my script is so wrong i wish, when a add points, nothing change, so you guys can help me?

Asked by 3 years ago
Edited 3 years ago

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)
0
Could you please attempt to put the script together so it is easier to read? It is very tricky otherwise to read. RAFA1608 543 — 3y
0
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. RAFA1608 543 — 3y
0
can you help me with another script? G4M3RZ1NH00 17 — 3y
0
Sure. RAFA1608 543 — 3y
0
Are you Brazilian? G4M3RZ1NH00 17 — 3y

Answer this question