My script does not fire an event to the server when it is supposed to. How do you fix this issue?
So I just started learning FilteringEnabled, and I wanted to learn it while I am making a battle royale game. I wanted a local script to fire an event to the server so that a script picks it up, but the local script does not even fire at all! So, here is the local:
01 | local Gib = game.ReplicatedStorage:WaitForChild( "Gib" ) |
02 | Player = game.Players.LocalPlayer |
03 | Mouse = Player:GetMouse() |
04 | tool = script.Parent.ToolData |
05 | k = script.Parent.HotkeyData |
11 | if (key = = k.Value) and game.ServerStorage:FindFirstChild(tool.Value) ~ = nil then |
13 | local Check = game.Players:FindFirstChild(Player) |
15 | Gib:FireServer(Check, "Hyperlaser" ) |
19 | if Player.Backpack:FindFirstChild(tool.Value) = = nil and Player.Character:FindFirstChild(tool.Value) = = nil then |
20 | local weapon = game.ServerStorage:FindFirstChild(tool.Value):clone() |
21 | weapon.Parent = Player.Backpack |
23 | Player.PlayerGui:FindFirstChild( "HotKeyGuiThing" ):remove() |
24 | until Player.PlayerGui:FindFirstChild( "HotKeyGuiThing" ) = = nil |
25 | if workspace:FindFirstChild( "Weapon Crate" ) then workspace [ "Weapon Crate" ] :Destroy() |
32 | Mouse.KeyDown:connect(Press) |
35 | Player.PlayerGui:FindFirstChild( "HotKeyGuiThing" ):remove() |
36 | until Player.PlayerGui:FindFirstChild( "HotKeyGuiThing" ) = = nil |
And here is the Script:
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local Players = game:GetService( "Players" ) |
04 | local RemoteEvent = Instance.new( "RemoteEvent" ,ReplicatedStorage) |
05 | RemoteEvent.Name = "Gib" |
07 | local function ForThePlayers(Player, Item) |
08 | print ( "Event recieved" ) |
09 | if Player.Backpack:FindFirstChild(Item.Value) = = nil and Player.Character:FindFirstChild(Item.Value) = = nil then |
10 | local weapon = game.ServerStorage:FindFirstChild(Item.Value):clone() |
11 | weapon.Parent = Player.Backpack |
12 | print ( "Event executed" ) |
15 | RemoteEvent.OnServerEvent:Connect(ForThePlayers) |
My script might have some other issues, because what I like to do is to take some scripts from the RWiki and change them to my command, because I am still a beginner scripter, so please don't judge my skill. And if you do find those issues, give feedback please.