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

Why my UI moneys does no change if I change the money Value while I'm in game?

Well, I'm really new whit roblox studio (not more than a few week), and now i have my first hard problem: For testing my knowledge, I wanted to try to make a simulator-kind game, I made an UI and I scripted a few "power" (in-game value; you can earn it jumping), but whit this "power" i started having some troubles, even if i was able to make a leaderboard money, and an uptading UI, I've seen that if i change the "power value" while I'm in-game trought explorer (the intvalue),the shop's money indicator UI do not change.

The first code i'll write here is gonna be the UI local script.

local Player = game:GetService("Players").LocalPlayer
local PlayerName = Player.Name
local power = Player.leaderstats.PlayerPower.Value
local UserInputService = game:GetService("UserInputService")


local function onInputEnded(inputObject, gameProcessedEvent)
	if gameProcessedEvent then return end
	if inputObject.UserInputType == Enum.UserInputType.Keyboard then
		if inputObject.KeyCode.Name == "Space" then
			wait(0.1)
			power = power + 1
			Player.leaderstats.PlayerPower.Value = power
			script.Parent.Text = power
		end
	end
end

UserInputService.InputBegan:Connect(onInputEnded)

The second one the money script itself.

power = "Power"
starterPower = 0

game.Players.PlayerAdded:connect(function(plr)
	local fold = Instance.new("Folder", plr)
	fold.Name = "leaderstats" 
	val = Instance.new("IntValue", fold)
	val.Name = "Power"
	val.Value = starterPower
end)

1 comment

0

The problem is its in a local script. If I were you, I'd use a remote event that fires when the space bar is pressed, and then connect that remote event with a regular script stating that when the remote event fires, it will add +1 to your value. The local script only shows for you, not for everyeone.

1 answer

You need to change your stats on the server. You have changed it on the client!

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