Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Mystdar 352 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by
Kurieita 125
8 years ago
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 :)

0
Thanks, but it still does not work Mystdar 352 — 8y
Ad

Answer this question