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

Value script works but doenst change in-game?

Hello, i am just trying to make a script that works like this: U click a part, the part makes the gui text change +1, Click again, gui text goes +1 again..

Now although this does seem to work, and the value changes.. it doesnt appear to change in-game, heres my script:

I have a Part that is able to click and a value inside the gui that makes the text change,

local clicky = script.Parent.ClickDetector
local value = game.StarterGui.NumberV.Value
local number = game.StarterGui.NumberV.Number


local function onClicked()
	game.StarterGui.NumberV.Number.Text = game.StarterGui.NumberV.Value.Value
	
	if value.Value >= 0	then
		value.Value = value.Value + 1
	end
end

clicky.MouseClick:Connect(onClicked)

hope anyone can help me, Thank u for reading

2 comments

0

how did it not work

0

i dont know tbh, it does the same exact thing.. and still doesnt change it on screen or in-game

1 answer

✓ Accepted answer

You are modifying the one in StarterGui. Which means this won't show to the player until they respawn.

You want to modify the GUI they are actually seeing which is the one in PlayerGui.

Make your script a local script and put it in startergui.

local click_detector = ... -- fill in wherever it is in the workspace

local value = script.Parent.NumberV.Value
local number = script.Parent.NumberV.Number

click_detector.MouseClick:Connect(function()
	number.Text = value.Value

	if value.Value >= 0 then
		value.Value += 1
	end
end)

2 comments

0

alright i will try this, give me a moment ;D

0

It still does the same for some reason?

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