Hi, I'm trying to make a tool that makes a part appear and the part moves to the player's mouse's Position.
I'm trying to use the Changed event instead of a while true do wait loop, but it doesn't seem to be working.
I'm getting this error:
14:46:38.400 - Players.Player1.Backpack.Build.LocalScript:13: attempt to index field 'x' (a number value)
I don't see why it's trying to index it when it's a number value. Also, is there any event that fires when Any part of the CFrame is changed? So I don't need to rely on just .x or something.
This is the script.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local CF = mouse.Hit
part = Instance.new("Part")
part.Parent = game.ReplicatedStorage
part.Anchored = true
part.BrickColor = BrickColor.Red()
script.Parent.Equipped:connect(function(mouse)
print("Equipped")
part.Parent = workspace
CF.x.Changed:connect(function()
part.Position = Vector3.new(CF.p)
end)
end)

2 comments
Because .Changed can not be used on number values. Indexing means finding something within something. In your case you're trying to index into x which is a number value. Use mouse.Move http://wiki.roblox.com/index.php?title=API:Class/Mouse/Move
Thank you, it'll try that out!