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
9 years ago

Firstly: prepare yourself for some horrendous scripting that may seriously make you cry, I am quite new. This script is basically meant to make a box (target box) then move the smoke to the target destination. When you press Q, in a tool.

local tool = script.Parent
    local spawned = false
     game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
    if string.lower(key) ==  "q" then
       if player.script.Parent.Parent.Parent.Parent.Parent.leaderstats.Lvl.Value>=2 and player.script.Parent.Parent.Mana.Value>=20 then
 if spawned then return end

        local target = mouse.Target
        local 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
end)

function onButton1Down(mouse)
game.Workspace.Union.BrickColor = BrickColor.new(29)
a.Anchored=False --So it can't move (I think)
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()
function onEquipped(mouse)

function onEquipped(mouse)
      mouse.Button1Down:connect(function () onButton1Down(mouse) end)
    end


tool.Equipped:connect(onEquipped)


I probably missed a LOT of ends and I must apologies for my incompetence. Thank you in advance. Please bear with me in your explanations. 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

0
Where do you set a local called grime? Look at this wiki page: http://wiki.roblox.com/index.php?title=BrickColor damagex443 325 — 9y
0
Edited, thanks :D Mystdar 352 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Here's your script, copy this using the 'copy to clipboard' tool you see in the top right corner when hovering your mouse over the script. I don't know if this script works like you want it to, but I cleaned it up a bit. Really, look at how i structured the code and try to use that same structure too. Don't use spacebar in front, just hit tab once. This gives you a much better overview of what you're doing.

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))

Also make sure that you're running this inside a LocalScript. If not

-- Change:
local Player = game.Players.LocalPlayer
-- To:
local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
0
Wow! I'll test this in a minute, Thanks! Sorry I missed the takeaway Mana line (I believe it should go under line 10) takes away 20 Mana. Thanks Mystdar 352 — 9y
0
It doesn't seem to work for me, so i'll make a new post with your script and go from there. Thanks, btw Mystdar 352 — 9y
Ad

Answer this question