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

[SOLVED] attempt to perform arithmetic on field 'Value' (a userdata value)?

I made a script that resizes a gui by a cars speed (magnitude) (dunno if it works) but it always gives me Players.ieatandisbaconhair.PlayerGui.ScreenGui.LocalScript:9: attempt to perform arithmetic on field 'Value' (a userdata value). The value does have something in it.

Cloning the gui script:

script.Parent.ChildAdded:Connect(function(child)
	if child:IsA("Weld") then
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		local e = script.ScreenGui:Clone()
		e.Parent = plr:WaitForChild("PlayerGui")
		e.Car.Value = script.Parent.Parent
	end
end)

the script inside the gui:

local gui = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")

script.Parent.Car.Value.VehicleSeat.ChildRemoved:Connect(function(child)
	if child:IsA("Weld") then
			script.Parent:Destroy()
	end
end)

gui.bar:TweenSize(UDim2.new(script.Parent.Car.Value.VehicleSeat.Velocity.Magnitude/script.Parent.Car.Value.Value,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,.5,true)

ty

9 comments

0

Did you keep the default name of a value object if so then you need Value.Value

0

no, its called car

0

Which type of value is Car?

0

I believe that script.Parent.Car.Value.Value isn’t a value, it’s an instance.

0

Car is an ObjectValue?

0

I'm sorry but that name makes it hard for us to take you seriously and what about your own convenience, what's with that huge name and formatted poorly. I'm referring to "ieatandisbaconhair" in case you didn't catch on.

0

Is "Value" a descendant of the Car's Value? Look at the 2nd part of line 9, that's what's giving you trouble. "script.Parent.Car.Value.Value" That's not correct

0

it actually is supposed to be car.Value.Value. Because, in the car, i have a value called Value.

0

nvm fixed it lol

1 answer

Hey,

I don’t have a super clear understanding of your issue but could it be possible you have a value named value as a child of another value? If so, you could use :FindFirstChild().

Your line 9 would look like this...

gui.bar:TweenSize(UDim2.new(script.Parent.Car.Value.VehicleSeat.Velocity.Magnitude/script.Parent.Car:FindFirstChild(“Value”).Value,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,.5,true)

If this helped, remember to accept and upvote the answer.

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