16:34:26.812 - Players.Sandessat.Backpack.FireBlast.settings:7: attempt to index local 'player' (a nil value)
Here’s the code:
-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")
-- Variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local remoteEvent = replicatedStorage.ElementsRemoteEvents.Fire.FireballRain.FireballRainRemoteEvent
local playerMouse = player:GetMouse()
local tool = script.Parent
-- Settings
local debounce = true
local key = 'One'
local keyPad = 'KeypadOne'
tool.Activated:Connect(function()
print("Clicked!")
userInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
print("Working UIS")
local keyPressed = input.KeyCode
if keyPressed == Enum.KeyCode[key] and debounce and character then
debounce = false
remoteEvent:FireServer(playerMouse.Hit)
wait(4)
debounce = true
elseif keyPressed == Enum.KeyCode[keyPad] and debounce and character then
debounce = false
remoteEvent:FireServer(playerMouse.Hit)
wait(4)
debounce = true
end
end)
end)
When I click with the tool, nothing happends, and the prints that I added does not shows anything, here’s my complete console:
16:42:33.524 - Crazy Things! auto-recovery file was created
16:42:37.040 - loadstring() is not available
16:42:37.040 - Stack Begin
16:42:37.041 - Script 'Plugin_333714778.Script', Line 457
16:42:37.041 - Stack End
Don’t nest a InputBegan event in an Activated event, you’re pretty much making a whole lot of listeners that can cause potential memory leaks and performance issues every time you click
Also, what is in the console doesn’t relate to your script
The plugin wouldn’t have interfered with your script. The issue is probably because of your nested connections - take the InputBegan event out of the Activated event, put it outside the script and make a variable that will set to true whenever the activated event is fired, and set to false when the tool is deactivated(or whatever), and the InputBegan will account for that variable
Make sure you understand how to use the client and server in your scripting, this is very important and the reason why errors like this can occur in your programming. Here is a little article to help you learn upon this: Client-Server Runtime | Documentation - Roblox Creator Hub
-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
-- Variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local remoteEvent = replicatedStorage.ElementsRemoteEvents.Fire.FireBlast.fireBlastEvent
local playerMouse = player:GetMouse()
local tool = script.Parent
-- Settings
local debounce = true
tool.Activated:Connect(function()
if debounce == true then
debounce = false
remoteEvent:FireServer(playerMouse.Hit)
wait(4)
debounce = true
end
end)