UIS.InputBegan possibly not working?

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make a barrage for a JJBA game I’m working on.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that (possibly) one of my local scripts called “BarrageClient” won’t even run and displays no errors in the output.
    image

image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried putting prints in the script that fires the remote events to see where the error is coming from and even they don’t run, so I’m now starting to suspect that’s where the problem is.

LocalScript named “BarrageClient”:

local uis = game:GetService("UserInputService")

local barrage = game.ReplicatedStorage:WaitForChild("Barrage")

uis.InputBegan:Connect(function(key, typing)
	if typing then return end
	
	if key.KeyCode == Enum.KeyCode.E then
		barrage:FireServer(true)
		print("B")
	end
end)

uis.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E then
		barrage:FireServer(false)
		print("A")
	end
end)

ModuleScript named “BarrageHandler”:

local tsv2 = require(game.ReplicatedStorage.TSV2)
local info = TweenInfo.new(.13, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut) 

local module = {}
module.__index = module

local ActiveBarrages = {}

function module.FindBarrage(character)
	if ActiveBarrages[character] then
		return ActiveBarrages[character]
	end
end

function module.CreateBarrage()
	return setmetatable({
		Character = nil,
		Animation = nil,
		MaxPunch = nil,
		CurrentPunch = nil, --wont change and PLEASE dont change :(
		Rate = .1
	}, module)
end

function module:StartBarrage()
	if ActiveBarrages[self.Character] then
		warn("Barrage already exists!")
		return
	end
	
	ActiveBarrages[self.Character] = self
	
	local stand = self.Character.AdsPlatinum
	local animator = stand.AnimatorController.Animator
	local weld = stand.StandWeld
	
	self.Animation = animator:LoadAnimation(self.Animation)
	
	tsv2:GetTweenObject(weld, info, {C1 = CFrame.new(0,-.32,2)}):Play()
	
	self.Animation:Play()
end

function module:StopBarrage()
	if not ActiveBarrages[self.Character] then
		warn("Barrage doesn't exist!")
	end
	
	local weld = self.Character.AdsPlatinum.StandWeld
	
	ActiveBarrages[self.Character] = nil
	
	tsv2:GetTweenObject(weld, info, {C1 = CFrame.new(2, -1, -2.5)}):Play()
	self.Animation:Stop()
end

return module

ServerScript named “BarrageS”

local event = game.ReplicatedStorage:WaitForChild("Barrage")
local barrageHandler = require(game.ServerStorage.BarrageHandler)

event.OnServerEvent:Connect(function(player, pressed)
	if pressed then
		local stand = player.Character.AdsPlatinum
		local barrage = barrageHandler.CreateBarrage()
		barrage.Character = player.Character
		barrage.Animation = stand.Animations.Barrage
		
		barrage:StartBarrage()
	else
		local barrage = barrageHandler.FindBarrage(player.Character)
		
		if barrage then
			barrage:StopBarrage()
		end
	end
end)

All the locations for these scripts would have been listen above.

Also the stand gets cloned into the workspace and the stand name is AdsPlatinum (which contains the BarrageClient script.)

What moves BarrageClient into the client so the local script can run?

Well, when the player presses Q, the stand gets cloned into the workspace so I guess that may be the problem. However, I’ve tried putting it in other places where local scripts actually run yet it still doesn’t work.

Thing is, once you put it someplace that works, you need to make sure putting it into that place replicated to the client you want also. When testing, can you see the script from the client, and are there any signs that it runs at all?

Wait, it just starting working all of a sudden.
Now that I changed its parent, now it works, thanks :smiley:

1 Like