i am getting "Offset cannot be assigned to" on line 12 and I dont know what is wrong
I am trying to make a custom health system and it worked up until I tried making the rads (Radiation from fallout) remove from your total health when it reached the same point as your total (make it so that the rad is always the max it can be filled)
Here is the health bar without rads: https://gyazo.com/82168c6511258c544ad3b5ae690c3600
A red line from the end closest the the center will appear when there is at least one rad(s).
it uses remote events so it can fire from anywhere, the scripts that fire it dont have any issue its only when I try lowering the health I have an issue.
This is the layout of the game from StarterGui: https://gyazo.com/0494c3fd3e7574fb9f06cc6b447ec629
and yes it works from startergui because I am getting the remoteEvent fired on hit with hit.Name being the player
Code:
x = 0
y = 0
script.RemoteEvent.OnServerEvent:connect(function()
x = x - 1
y = y + 1
if (script.Parent.Parent.Health.size.X.Offset == script.Parent.Size.X.Offset + 250) then
print ("same")
print(y)
script.Parent.Parent.Health.healthVal.Value = script.Parent.Parent.Health.size.X.Offset
script.Parent.Parent.Health.Size.X.Offset = script.Parent.Parent.Health.size.X.Offset - y
end
script.Parent.RadVal.Value = script.Parent.RadVal.Value + 1
script.Parent.Size = UDim2.new(0,x,1,0)
end)

1 comment
I got an error like this as well, and the only solution I could do is create a Variable that saves the old GUI Position, then subtract the GUI's Position by the Variable minus the Position taken off (GUI.Position = GUIVar - UDim2.new(0.1, 0, 0, 0)). :(