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:
local Gib = game.ReplicatedStorage:WaitForChild("Gib") Player = game.Players.LocalPlayer Mouse = Player:GetMouse() tool = script.Parent.ToolData k = script.Parent.HotkeyData buttonPressed = false function Press(key) if (key == k.Value) and game.ServerStorage:FindFirstChild(tool.Value) ~= nil then local Check = game.Players:FindFirstChild(Player) if Check then Gib:FireServer(Check, "Hyperlaser") print ("Event fired") end if Player.Backpack:FindFirstChild(tool.Value) == nil and Player.Character:FindFirstChild(tool.Value) == nil then local weapon = game.ServerStorage:FindFirstChild(tool.Value):clone() weapon.Parent = Player.Backpack repeat Player.PlayerGui:FindFirstChild("HotKeyGuiThing"):remove() until Player.PlayerGui:FindFirstChild("HotKeyGuiThing") == nil if workspace:FindFirstChild("Weapon Crate") then workspace["Weapon Crate"]:Destroy() end end end end Mouse.KeyDown:connect(Press) wait (2) repeat Player.PlayerGui:FindFirstChild("HotKeyGuiThing"):remove() until Player.PlayerGui:FindFirstChild("HotKeyGuiThing") == nil
And here is the Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local RemoteEvent = Instance.new("RemoteEvent",ReplicatedStorage) RemoteEvent.Name = "Gib" local function ForThePlayers(Player, Item) print ("Event recieved") if Player.Backpack:FindFirstChild(Item.Value) == nil and Player.Character:FindFirstChild(Item.Value) == nil then local weapon = game.ServerStorage:FindFirstChild(Item.Value):clone() weapon.Parent = Player.Backpack print ("Event executed") end end 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.
Local Script works like this;
local PrintEvent = game.ReplicatedStorage:WaitForChild('Print') -- Print is a RemoteFunction local Text = "test" -- this is what will be sent to the server script by the local script --Fire the PrintEvent to the server PrintEvent:FireServer(Text) -- sends Text to the server script
Server Script
local PrintEvent = game.ReplicatedStorage:WaitForChild('Print') PrintEvent.OnServerEvent:connect(function(player, text) -- the first parameter is always the player who fired the PrintEvent from a localscript print("recieved " .. text .. " from" .. player.Name .. "!") end)