Script works when 1 player is in the game but doesn’t work when at least 2 players are in the game.
I haven’t found any other topics about this, there might be but I can’t find them so I’m making one.
I made a flashlight LocalScript where the player presses F, their character would show a flashlight on their Left Hand. I used FireServer() for this to connect to a Script on the Character, it all works fine when there is 1 player in the game, but doesn’t work when there is 2 players or more.
I’m not too good at scripting, so I can’t find the issue for this. Nothing shows on output or anything.
Also to mention, I’m using a StarterCharacter that has a Flashlight Inserted on the left arm.
I tried printing to see if the script goes through completely, they all printed correctly but the rest of the script doesn’t work.
Local Script (In StarterPlayerScripts)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local plr = Players.LocalPlayer
local FlashlightTrigger = ReplicatedStorage:WaitForChild("FlashlightTrigger")
UIS.InputBegan:Connect(function(input, gameProccessedEvent)
if input.KeyCode == Enum.KeyCode.F then
FlashlightTrigger:FireServer()
print("Fired to Server")
end
end)
Script (In Player’s Character)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FlashlightTrigger = ReplicatedStorage:WaitForChild("FlashlightTrigger")
local function TriggerFlashlight(player)
print(player.Name)
local Flashlight = player.Character["Left Arm"]:FindFirstChild("Flashlight")
player.Tools.FlashlightEquipped.Value = not player.Tools.FlashlightEquipped.Value
if player.Tools.FlashlightEquipped.Value == true then
Flashlight.Transparency = 0
elseif player.Tools.FlashlightEquipped.Value == false then
Flashlight.Transparency = 1
end
Flashlight.Flash.Enabled = not Flashlight.Flash.Enabled
print("Script Worked")
end
FlashlightTrigger.OnServerEvent:Connect(TriggerFlashlight)
I hope I put enough information for this.