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

What's a UserData Value and how I fix it?

I was trying to use a event called InterpolationFinished but I got a error,how do I fix it,and what does it mean?

Output: Workspace.Player1.Right Leg.LocalScript:9: attempt to call method 'InterpolationFinished' (a userdata value)

Script that gives the LocalScript:

local Part = script.Parent.Part
local Touched = false
--------------------------
	Part.Touched:connect(function(Player)
		Touched = true
			if  not Touched
				then
				Wait(5)
				Touched = false
				else
					for _,Scripts in pairs (script:GetChildren()) do
						Cloned = Scripts:Clone()
						Cloned.Parent = Player
						Cloned.Disabled = false
			end
		end
	end)

LocalScript:

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = game.Workspace.CurrentCamera
local Part = game.Workspace.Model.Part
local Part1 = game.Workspace.Model.Part1
-------------------------------------------
	Camera.CameraType = "Scriptable"
	Camera:Interpolate(CFrame.new(Part.CFrame.lookVector), CFrame.new(Part.CFrame.p),1)
	Camera.InterpolationFinished:connect(function()
	Camera.CameraSubject = Part
	Camera.CameraType = "Attach"
	end)

1 answer

userdata is a C object that Lua has access to.

This means it's something that the underlying engine (i.e., ROBLOX) has created.

userdata includes Vector3, CFrame, BrickColor, and all Instances.


Because of this, errors involving userdata aren't usually very helpful.


In this case though, I don't see how this error could be triggered by this code. You aren't calling "InterpolationFinished" so I don't see the problem.

6 comments

0

How can I call it?

0

No, you shouldn't be calling it; the error says you attempted to but I don't see that expressed in this snippet

0

So is there a way to fix it?

2

Try adding a wait() after you call Interpolate. As long as the user's computer isn't lagging to he point of crashing, it will let the event connect before the interpolation finishes, although this error shouldn't be occurring in the first place.

0

Thanks it worked!

0

You should be using Color3 as of 2020's updates not Vector3

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