#I need help

1 messages · Page 1 of 1 (latest)

autumn turtle
#

i need help changing the script so the attack starts when i press the button and not when i release it

timber crane
#

uh

#

where code

autumn turtle
#

wait

#

--SERVICES --
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")

-- BASIC VARIABLES --
local Player = game.Players.LocalPlayer
local Char
local HumRP

local Tool = script.Parent

-- VALUES --
local Equipped = script:WaitForChild("Equipped")
local Holding = script:WaitForChild("Holding")
local Using = script:WaitForChild("Using")

-- FOLDERS --
local Remotes = RS:WaitForChild("Remotes")
local Modules = RS:WaitForChild("Modules")
local anim1 = script:WaitForChild("AnimationCharge")
local anim2 = script:WaitForChild("AnimationRelease")
-- REMOTES --
local SkillsHandler = script.RemoteEvent

local sound = script:WaitForChild("Lava")
-- MOUSE --
local Mouse = Player:GetMouse()
local deb = false
-- FUNCTIONS --
Tool.Equipped:Connect(function()
-- PLAY IDLE
SkillsHandler:FireServer("Equip")
Char = Tool.Parent
HumRP = Char:WaitForChild("HumanoidRootPart")

end)

Tool.Unequipped:Connect(function()
-- STOP IDLE
SkillsHandler:FireServer("Unequip")
end)

#

UIS.InputBegan:Connect(function(Input, isTyping)
if isTyping then return end

if Input.KeyCode == Enum.KeyCode.Z and deb == false and Tool.Active.Value == "None" then
    if Equipped.Value and Holding.Value == "None" and not Using.Value then
        deb = true
        SkillsHandler:FireServer("Hold", "Z")
        script.ArmEvent:FireServer()
        Tool.Active.Value = "Yes"
        wait(9)
        deb = false
    end
end

end)

UIS.InputEnded:Connect(function(Input, isTyping)
if isTyping then return end

if Input.KeyCode == Enum.KeyCode.Z then
    if Holding.Value == "Z" then
        SkillsHandler:FireServer("Z", Mouse.Hit.Position)
        spawn(function()
            wait(2)
            Tool.Active.Value = "None"
        end)
        script.ArmEventDown:FireServer()
        local Track2 = Char.Humanoid:LoadAnimation(script.AnimationRelease)
        Track2:Play()
        Track1:Stop()


        sound1:Destroy()
    end
end

end)

Holding:GetPropertyChangedSignal("Value"):Connect(function()
if Holding.Value ~= "None" then
HumRP.Anchored = true
if Holding.Value == "Z" then

        sound1 = sound:Clone()
        sound1.Parent = Char["Right Arm"]
        sound1:Play()



        Track1 = Char.Humanoid:LoadAnimation(script.AnimationCharge)
        Track1:Play()


        repeat
            HumRP.CFrame = CFrame.lookAt(HumRP.Position, Mouse.Hit.Position)
            task.wait()
        until Holding.Value ~= "Z"
    end
else
    HumRP.Anchored = false
end

end)

#

its one code

timber crane
#

bro

#

post like this

code
autumn turtle
#

how

timber crane
#

surround by 3 `

autumn turtle
#

k

timber crane
#

do a test

#

test

#

oops

autumn turtle
#

'''Test'''

#

oops

#

TEST

timber crane
#

yea, do with the whole script now

autumn turtle
#

--SERVICES --
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")

-- BASIC VARIABLES --
local Player = game.Players.LocalPlayer
local Char
local HumRP

local Tool = script.Parent

-- VALUES --
local Equipped = script:WaitForChild("Equipped")
local Holding = script:WaitForChild("Holding")
local Using = script:WaitForChild("Using")

-- FOLDERS --
local Remotes = RS:WaitForChild("Remotes")
local Modules = RS:WaitForChild("Modules")
local anim1 = script:WaitForChild("AnimationCharge")
local anim2 = script:WaitForChild("AnimationRelease")
-- REMOTES --
local SkillsHandler = script.RemoteEvent

local sound = script:WaitForChild("Lava")
-- MOUSE --
local Mouse = Player:GetMouse()
local deb = false
-- FUNCTIONS --
Tool.Equipped:Connect(function()
    -- PLAY IDLE
    SkillsHandler:FireServer("Equip")
    Char = Tool.Parent
    HumRP = Char:WaitForChild("HumanoidRootPart")

end)

Tool.Unequipped:Connect(function()
    -- STOP IDLE
    SkillsHandler:FireServer("Unequip")
end)
#

first part

#
    if isTyping then return end

    if Input.KeyCode == Enum.KeyCode.Z and deb == false and Tool.Active.Value == "None" then
        if Equipped.Value and Holding.Value == "None" and not Using.Value then
            deb = true
            SkillsHandler:FireServer("Hold", "Z")
            script.ArmEvent:FireServer()
            Tool.Active.Value = "Yes"
            wait(9)
            deb = false
        end
    end
end)

UIS.InputEnded:Connect(function(Input, isTyping)
    if isTyping then return end

    if Input.KeyCode == Enum.KeyCode.Z then
        if Holding.Value == "Z" then
            SkillsHandler:FireServer("Z", Mouse.Hit.Position)
            spawn(function()
                wait(2)
                Tool.Active.Value = "None"
            end)
            script.ArmEventDown:FireServer()
            local Track2 = Char.Humanoid:LoadAnimation(script.AnimationRelease)
            Track2:Play()
            Track1:Stop()


            sound1:Destroy()
        end
    end
end)

Holding:GetPropertyChangedSignal("Value"):Connect(function()
    if Holding.Value ~= "None" then
        HumRP.Anchored = true
        if Holding.Value == "Z" then



            sound1 = sound:Clone()
            sound1.Parent = Char["Right Arm"]
            sound1:Play()



            Track1 = Char.Humanoid:LoadAnimation(script.AnimationCharge)
            Track1:Play()


            repeat
                HumRP.CFrame = CFrame.lookAt(HumRP.Position, Mouse.Hit.Position)
                task.wait()
            until Holding.Value ~= "Z"
        end
    else
        HumRP.Anchored = false
    end
end)```
#

its one code

timber crane
#

why are you firing the event in input ended function

autumn turtle
#

i didnt write the code

timber crane
#

bruh

#

change it so that it fires in inputbegan instead of inputended

#

I cant rlly help you if you dont know how to code

autumn turtle
#

i know a little

#

not nothing

autumn turtle
timber crane
#

alr

autumn turtle
#

what exactly should i transfer

#

didnt work

#

i mean should i delete input ended?

timber crane
#

no

wicked bobcat
#

put the lua code tag so i dont read white text