#My script wont work once I use a keycode function PLEASE RESPOND help :(((((((((((((((((((((((((((

7 messages · Page 1 of 1 (latest)

jovial olive
#

This is a gun tool. When I go to use userinput service then detect when the player presses r it wont work.

#

THIS IS NOT STOLEN SO DON't SAY THAT its mean 😠

#

LOCAL SCRIPT:

reloadremote = game.ReplicatedStorage.UISRELOAD
local UIS = game:GetService("UserInputService")

local player = game.Players.LocalPlayer

local PlayerGUI = player.PlayerGui

repeat wait(1) until
player.Character

local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

tool = script.Parent

local anims = tool:WaitForChild("Animations")

local shoot = anims:WaitForChild("Shoot")
local reload = anims:WaitForChild("Reload")
local hold = anims:WaitForChild("Idle")

local shootanim = humanoid:LoadAnimation(shoot)
local holdanim = humanoid:LoadAnimation(hold)
local reload = humanoid:LoadAnimation(reload)

local MagAMOUNT = tool.Magazine

print(tostring(tool.Magazine.Value))

tool.Equipped:Connect(function()
    MagAMOUNT.Value = MagAMOUNT.Value
    holdanim:Play(0.2)
    
    wait()
    PlayerGUI.GunGUI.Enabled = true
    
    
end)

tool.Unequipped:Connect(function()
    PlayerGUI.GunGUI.Enabled = false
    holdanim:Stop()
end)


tool.Activated:Connect(function()
    shootanim:Play()
    game.ReplicatedStorage.FireRevolver:FireServer()
    wait(0.02)
end)


while true do
    wait()
    PlayerGUI.GunGUI.Frame.Mag.Text = tostring(tool.Magazine.Value)
end


UIS.InputBegan:Connect(function(input)
    print("LSZKXUHGOPIRS")
    if input.KeyCode == Enum.KeyCode.R and MagAMOUNT.Value == 0 then
        reloadremote:FireServer()
        print("reloadanimplay")
        reload:Play()
    else 
        print("slifdghulierujhgelirughelriguherlkgjehrglkjehrglkhjglkerjtghlkerjhglkhjgljkghlkjhfg")
        end
    end)
#

SERVER SCRIPT:

local UIS = game:GetService("UserInputService")

reloadremote = game.ReplicatedStorage.UISRELOAD

tool = script.Parent
remote = game.ReplicatedStorage.FireRevolver
valueofmagazie = print(tostring(tool.Magazine.Value))

local MagAMOUNT = tool.Magazine


game.ReplicatedStorage.FireRevolver.OnServerEvent:Connect(function()
    if MagAMOUNT.Value >= 0.9 then
        wait(0.01)
    tool.Flash.FireSound:Play()
    tool.Flash.MuzzleFlash.Enabled = true
        tool.Flash.Light.Enabled = true
        tool.Magazine.Value = tool.Magazine.Value - 1
    wait(0.1)
    tool.Flash.MuzzleFlash.Enabled = false
    tool.Flash.Light.Enabled = false
        
        
    elseif MagAMOUNT.Value <= 0 or MagAMOUNT.Value == -1 then
        tool.Flash.EmptyMag:Play()
        MagAMOUNT.Value = 0
    end
end)


tool.Equipped:Connect(function()
    MagAMOUNT.Value = tostring(tool.Magazine.Value)
end)

reloadremote.OnServerEvent:Connect(function()
    print("LSZKXUHGOPIRS")
        print("reload")
        tool.Flash.Reload:Play()
        reloadremote:FireClient()
        wait(2.6)
        MagAMOUNT.Value = 6
end)

they are in a tool

austere thistleBOT
#

studio** You are now Level 13! **studio

jovial olive
#

I am beginner so pls

white crescent
#

bro relax on the title