Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.