Help with a beam firing script

The error that I have notice is that when I press Q nothing happens and there is no error/output at all in the Output tab.

local uis = game:GetService(“UserInputService”)
local tool = script.Parent
local serverStorage = game:GetService(“ServerStorage”)
local beam = serverStorage.characterItemsAndAttacks.adminSans.blasters.beam
db = false

local firing = function()
if db==false then
print(“start”)
db=true
local beamClone=beam:Clone()
beamClone.Parent=script.Parent.Parent.Character.RightArm
beamClone.CFrame=script.Parent.Parent.Character.RightArm.CFrame*CFrame.new(1000,0,0)
beamClone.Size=Vector3.new(2000,100,100)
wait(1)
beamClone:Destroy()
db=false
print(“end”)
end
end

tool.Equipped:Connect(function()
uis.InputBegan:Connect(function(input, gpe)
if input.UserInputType==Enum.UserInputType.Keyboard then
if input.KeyCode==Enum.KeyCode.Q then
firing()
print(“success!”)
end
end
end)
end)

In the topic the script does not have spacing for some reason, sorry.

Forgot to mention, the script is not done but should work regardless.

Hey there, can you properly format this script using ``` at the beginning and end? If you do so it’ll be easier for us to analyse your script.

1 Like

Hey there I think I found the mistake, can you tell me whether if it’s a local or a server script?

Read over the script again. This won’t work. Parts don’t replicate to the server via localscripts and UserInputService won’t work with normal scripts. To make this work you would need to split the UserInputService and the rest of the code into a localscript and a script bridged by a RemoteEvent. I can try and write the script out for you later if you need.

1 Like

thank you guys for the help, sorry i didnt reply right away, this goes for everyone. ill look into it and come back when i have redone the script. this is a server script btw

this is a server script, whats the mistake?

1 Like

User input service must be used from a local script! I believe that may be the error.

1 Like

i know this is dead, but i figured if someone decides to read this looking for help, id answer my own question. first, is something most people pointed out, there needs to be both a local and server script, replicating between one another. second, and another fair argument made before, is that the script was formatted poorly when i sent it, on top of that, the tool.Equipped event is being used completely wrong lol. ill rewrite this in a moment, and post the fixed code.