Changing values | Not working?

Hi, thanks for reading to help me.

Basically what I’m trying to figure out is why my value isn’t changing. This is all client side so it shouldn’t be an FE issue as it’s all in their GUI.

local plr = game.Players.LocalPlayer.Name
local repstorage = game:GetService("ReplicatedStorage")
local viewportchar = script.Parent.Parent.Parent.ViewportFrame:WaitForChild(plr.."CLONED")
local event = repstorage:WaitForChild("PlayerAvatarGearClone")
local vesttype = "HiVisVest"
local onornot = script.Parent.Parent.VestOn.Value
script.Parent.MouseButton1Down:Connect(function()
	if viewportchar:FindFirstChild(vesttype) == nil and onornot == false then
		script.Parent.BackgroundColor3 = Color3.fromRGB(165,165,165)
		print("Fired")
		event:FireServer(vesttype, "On")
		onornot = true
	elseif viewportchar:FindFirstChild(vesttype) and onornot == true then
		script.Parent.BackgroundColor3 = Color3.fromRGB(66,66,66)
		event:FireServer(vesttype, "Off")
		onornot = false
	end
end)

What it’s supposed to do is check the value (‘VestOn’) and then do the things and switch it to the opposite. I’m not sure what I’ve done and I’ve got myslef into a bit of a pickle lol.

Any help is appreciated :slight_smile:

1 Like

You can’t link properties to variables. You’d have to set VestOn as the actual object and configure the value wherever you use the variable.

local onornot = script.Parent.Parent.VestOn

onornot.Value = true
1 Like

Hm, I’ve changed it but it now seems to do nothing.

(None of the if statements fire)