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

Script not working when I drag a particle in?

Asked by
bt6k 23
4 years ago

I will get right to the point...

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local Key = "E"
local Visible = true
local debounce = false

if plr.Team == game.Teams.ISD then
    local function Visibility(Var)
    if Var then
        for _, Part in pairs(char:GetDescendants())do
            if Part:IsA("BasePart") or Part:IsA("MeshPart") then
                Part.Transparency = 1
                char.Head.face.Transparency = 0
                char.HumanoidRootPart.Transparency = .5
                char.Humanoid.WalkSpeed = 40
                if not debounce then
                    local smoke = game.Lighting:WaitForChild("Smoke"):Clone()
                    debounce = true
                end
            end
        end 
    else
        for _, Part in pairs(char:GetDescendants())do
            if Part:IsA("BasePart") or Part:IsA("MeshPart") then
                Part.Transparency = 1
                char.Head.face.Transparency = 0
                char.HumanoidRootPart.Transparency = 0
                char.Humanoid.WalkSpeed = 16
                if debounce then
                    char.Head.Smoke:Destroy()
                end
            end
        end   
    end 
end
UserInputService.InputBegan:Connect(function(Input,GameStuff)
    if GameStuff then return end
    if Input.KeyCode == Enum.KeyCode[Key] then
        if Visible then
            Visibility(false)
            Visible = false
        else
            Visibility(true)
            Visible = true  
        end 
    end
end)
end

So basically, there is my head obv.. and this script is making me invisible. Now, once in the for loop, I make it so it makes one smoke particle from lighting get dragged into my head. The problem is, I took this script from youtube and attempted to modify it, and I think I broke it.. Can anyone explain to me what is going on in this script and how I could possibly make it so during the for loop where it is cycling through my body making it invisible, I could once, put a particle emitter in, then once that cycle has finished rotating, the next cycle removes that particle emmiter, and the process repeats, how many times you input the key, "E".

If you cannot tell aswell, this is cloning it from the Lighting, which the Smoke IS IN.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local Key = "E"
local Visible = true
local debounce = false

if plr.Team == game.Teams.ISD then
    local function Visibility(Var)
    if Var then
        for _, Part in pairs(char:GetDescendants())do
            if Part:IsA("BasePart") or Part:IsA("MeshPart") then
                Part.Transparency = 1
                char.Head.face.Transparency = 0
                char.HumanoidRootPart.Transparency = .5
                char.Humanoid.WalkSpeed = 40
                if not debounce then
                    local smoke = game.Lighting:WaitForChild("Smoke"):Clone()
                    debounce = true
                end
            end
        end 
--create particle emitter, after the first for loop ends
Instance.new("ParticleEmitter",char.Head)
    else
        for _, Part in pairs(char:GetDescendants())do
            if Part:IsA("BasePart") or Part:IsA("MeshPart") then
                Part.Transparency = 1
                char.Head.face.Transparency = 0
                char.HumanoidRootPart.Transparency = 0
                char.Humanoid.WalkSpeed = 16
                if debounce then
                    char.Head.Smoke:Destroy()
                end
            end
        end   
    end 
--remove particle emitter, after second for loop ends
pcall(function() char.Head:FindFirstChild("ParticleEmitter"):Destroy() end)
end
UserInputService.InputBegan:Connect(function(Input,GameStuff)
    if GameStuff then return end
    if Input.KeyCode == Enum.KeyCode[Key] then
        if Visible then
            Visibility(false)
            Visible = false
        else
            Visibility(true)
            Visible = true  
        end 
    end
end)
end

Ad

Answer this question