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

This part does not follow to user's cursor? edit

This script is supposed to make a part follow the mouse while it is held down but then go stationary when lifted why does it not do this? It prints Lift and press.

mouse = game.Players.LocalPlayer:GetMouse()
tool = script.Parent
spawned = false
final = false

function DownClick()
	print ("Press")
    if spawned == false then
		local target = mouse.Target
		q = game.Lighting.Beacon:Clone()
		q.Parent = game.Workspace
		q.Owner.Value = script.Parent.Parent.Name	
		q.Size = Vector3.new(3,3,3)
		q.Anchored = false
		q.CanCollide = false
		spawned = true
		print ("Checkpoint 1; passed")
		while spawned do
			wait()
		    q.Position = CFrame.new(Vector3.new(tool.Parent.Humanoid.TargetPoint.X,1,tool.Parent.Humanoid.TargetPoint.Z))
		end
	end
end

mouse.Button1Down:connect(DownClick)

function UpClick()
	print ("Lift")
	final = true
	q:findFirstChild("Ready") = true
	q.Anchored = true
end
mouse.Button1Up:connect(UpClick)

function onUnequipped()
	q:remove()
	spawned, final = false, false
end
script.Parent.Unequipped:connect(onUnequipped)

Output:

EDIT

15:54:43.768 - Players.Player1.Backpack.Test2.BeaconCreate:20: bad argument #3 to 'Position' (Vector3 expected, got CFrame)

1 answer

q:findFirstChild("Ready") = true

Should be

q:findFirstChild("Ready").Value = true

You're trying to set an object to true, which is illegal. You can set the value tho.

If this work, please vote up :)

1 comment

0

Thanks, but it still does not work

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