Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Power.Value = Power.Value not working?

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)

3 comments

0

what is the error

0

there isnt any error on output

0

This wont work! Local player cant change values. You can use a RemoteEvent, though!

2 answers

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.