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

Why Power.Value = Power.Value not working?

Asked by 5 years ago

can someone help me? Power.Value = Power.Value not working D:

This script is in PlayerCharacterScripts

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character

local Humanoid = Character:WaitForChild("Humanoid")

Humanoid.Jumping:Connect(function()
    local Power = Player:WaitForChild("leaderstats"):WaitForChild("Power")
    Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
    Power.Value = Power.Value +0.25
    wait(3)
    Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end)
0
what is the error ninjaguy77777 -6 — 5y
0
there isnt any error on output FrezeTagger 75 — 5y
0
This wont work! Local player cant change values. You can use a RemoteEvent, though! Microwosoft 7 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You could do something like this.

--// Client

local Update = game:GetService("ReplicatedStorage"):WaitForChild("Update")

Update:FireServer(.25)
--// Server

local Update = Instance.new("RemoteEvent")
Update.Name = "Update"
Update.Parent = game:GetService("ReplicatedStorage")

Update.OnServerEvent:Connect(function(Plr, Amount)
    assert(Amount, "Amount cannot be nil.")
    assert(type(Amount) == "number", "Amount must be of type number.")

    local LS = Plr:FindFirstChild("leaderstats")
    local Power = (LS and LS:FindFirstChild("Power")) or nil
    if LS and Power then
        assert(Power:IsA("ValueBase"), "Power must be of class ValueBase.")
        assert(type(Power.Value) == "number", "Value must be of type number.")

        Power.Value = Power.Value + Amount
    end
end)

I don't recommend this though, exploiters can use this to get an infinite amount of points.

Ad
Log in to vote
-1
Answered by 5 years ago

Make sure the script is a script, not a localscript. You cannot change values on the client side.

Answer this question