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

Help on this script?

Asked by
Mystdar 352 Moderation Voter
10 years ago

This script is meant to make a target box appear, then when you click the box stays at that position, the smoke is spawned and moved to the position, this should happen when you press Q . However it just doesn't seem to do anything, no obvious script errors in the debugger or Output either.

local tool = script.Parent
    local spawned = false
    local player = game.Players.LocalPlayer
    local mouse = player:GetMouse()
    local a = nil
    -- I added some local variables so they're easier to call from within the script

    mouse.KeyDown:connect(function(key)
        if string.lower(key) ==  "q" then
            if player.leaderstats.Lvl.Value>=2 and player.Mana.Value>=20 then -- Changed to new variables
                if spawned then return end
                local target = mouse.Target
                a = game.Lighting.union:Clone()
                a.Parent = Workspace
                a.Size = Vector3.new(3,3,3)
                a.Anchored = true
                a.CanCollide = False
                spawned = true
                while spawned do
                    wait()
                    a.CFrame = CFrame.new(Vector3.new(tool.Parent.Humanoid.TargetPoint.X,0,tool.Parent.Humanoid.TargetPoint.Z))
                end
            end -- This 'end' was missing
        end
    end)

    function onButton1Down(mouse)
        a.BrickColor = BrickColor.new(1022) -- Updated
        a.Anchored = false
        local smoke = game.lighting.Smoke:clone()
        smoke.parent = Workspace
        game.Workspace.smoke.CFrame = game.Workspace.union.CFrame+ Vector3.new(0, 4, 0)
        wait (5)
        a:remove()
        smoke:remove()
    end
    -- Here was an extra function onEquipped(mouse) that didn't end
    function onEquipped(mouse)
          mouse.Button1Down:connect(function () onButton1Down(mouse) end)
    end


    tool.Equipped:connect(onEquipped(mouse))

Just so you know, I have been helped with a script that has inserted two IntValues into the player called Mana, and MAXMana, for your reference it can be found here: https://scriptinghelpers.org/questions/10533/help-on-this-script-with-intvalues

1
Use 'Print(player.leaderstats.Lvl.Value)' after 'if string.lower(key) == "q" then' and check if it fires. Print() is a developers best friend. Do this step by step with each variable or after each statement to find out where your script stops. damagex443 325 — 10y
0
Mind if I edit the above script with all the prints in? I'll probably get a few wrong. Mystdar 352 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

I agree with Damagex443 Use the "Print Function" to check where your script doesn't respond anymore.

Ad

Answer this question