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

Gui Value Will Not Change When Clicked?

local Value = script.Parent.ClickValue
local Button = script.Parent
local Player = game.Players.LocalPlayer --get the local player
local Mouse = Player:GetMouse() --get the mouse
 
function ChangeValue()
Mouse.Button1Down:connect(function()
Value.Value = 1
end)
end
Mouse.Button1Down:connect(ChangeValue)

The problem is when i click the button it does not change the value at all to 1. Not sure what i have done wrong here.

1 answer

✓ Accepted answer
local Value = script.Parent.ClickValue
local Button = script.Parent
local Player = game.Players.LocalPlayer --get the local player
local Mouse = Player:GetMouse() --get the mouse

function ChangeValue()
Value.Value = 1
end
Mouse.Button1Down:connect(ChangeValue)

You've already told the code that when you click it, it should change it now :). You can check for errors by opening the output in the studio, it helps me a lot when finding errors :3

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