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

how to fix inputbegan is not a valid member of ReplicatedStorage "ReplicatedStorage"?

Asked by 2 years ago
local gun = script.Parent
local gun_shot = gun.Handle.Shoot
local empty_sound = gun.Handle.Empty
local reload_sound = gun.Handle.Reload




local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')

local userInput = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')

gun.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        if gun.Ammo.Value > 0 then
        remoteEvent:FireServer(gun.Handle.Position, mouse.Hit.p)
        gun_shot:Play()
            gun.Ammo.Value = gun.Ammo.Value - 1
        else
           empty_sound:Play()
            end
    end)

end)


userInput.InputBegan:Connect(function(input, gameProcessed)



    if not gameProcessed then

        if input.UserInputType == Enum.UserInputType.Keyboard then


            local keycode = input.KeyCode
            if keycode == Enum.KeyCode.R then
                reload_sound:Play()
                reload_sound.Ended:Wait()
                gun.Ammo.Value = 15
            end

    end
end
end)

help pls

1 answer

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
2 years ago

Description isn't really detailed, but here you go.

The GetService function in line 12 of your code isn't getting UserInputService. Change that into...

local userInput = game:GetService("UserInputService")
Ad

Answer this question