Yo guys i think am having a problem here.
the problem is when a player uses the flashlight and the other one does it stops at a player and starts at the other ones and vise versa.
i just want to make all of the players use it normally.
Yo guys i think am having a problem here.
the system is about Remotes in replicated storage and local script below the startercharacterscripts and a script in the serverscriptservice
Could you please show the scripts for this?
StarterCharacterScript local script:
local Input = game:GetService("UserInputService")
local Delevier= game:GetService("ReplicatedStorage").Remotes.Equip
local Delevier2= game:GetService("ReplicatedStorage").Remotes.Unequip
local Bool1 = script:WaitForChild("Bools"):FindFirstChild("CoolDown").Value
local Bool2 = script:WaitForChild("Bools"):FindFirstChild("Equipped/Unequipped").Value
local Script = script
Input.InputBegan:Connect(function(Key)
if Key.KeyCode == Enum.KeyCode.F and Bool1 == false and Bool2 == false then
Bool1 = true
Bool2 = true
print("Sending")
Delevier:FireServer(Bool1 , Bool2)
wait(0.75)
Bool1 = false
else
if Key.KeyCode == Enum.KeyCode.F and Bool1 == false and Bool2 == true then
Bool1 = true
print("Sending")
Delevier2:FireServer(Script)
wait(0.75)
Bool2 = false
Bool1 = false
end
end
end)
--Mobile
if Input.KeyboardEnabled == false and Input.MouseEnabled ==false then
if Bool1 == false and Bool2 == false then
game.Players.LocalPlayer.PlayerGui.FlashlightGUI.Enabled = true
local Button = game.Players.LocalPlayer.PlayerGui.FlashlightGUI.FlashLightButton
Button.MouseButton1Click:Connect(function()
if Bool1 == false and Bool2 == false then
Bool1 = true
Bool2 = true
print("Sending")
Delevier:FireServer(Bool1 , Bool2)
wait(0.75)
Bool1 = false
else if Bool1 == false and Bool2 == true then
Bool1 = true
Bool1 = true
print("Sending")
Delevier2:FireServer(Script)
wait(0.75)
Bool2 = false
Bool1 = false
end
end
end)
end
end
the serverscriptservice script:
local EquipRemote = game:GetService("ReplicatedStorage").Remotes.Equip
local UnEquipRemote = game:GetService("ReplicatedStorage").Remotes.Unequip
local FlashLight = game.ReplicatedStorage.FlashLightModel.Model:Clone()
local Animations = script.Animations
local EquipAnim = Animations.Equip
local UnEquipAnim = Animations.Unequip
local Weld = Instance.new("Motor6D",FlashLight.Grip)
local Allow = script.Value.Value
local Function1 = EquipRemote.OnServerEvent:Connect(function(Plr , Script)
--Variables
print(Script)
local Char = Plr.Character
local Load1 = Plr.Character:FindFirstChild("Humanoid"):LoadAnimation(EquipAnim)
local Load2 = Plr.Character:FindFirstChild("Humanoid"):LoadAnimation(UnEquipAnim)
---------------------------------------------------------------------------------
FlashLight.Parent = Char
Weld.Part0 = Char:FindFirstChild("Right Arm")
Weld.Part1 = FlashLight.Grip
Load1:Play()
UnEquipRemote.OnServerEvent:Connect(function()
Load1:Stop()
Load2:Play()
wait(0.7)
FlashLight:Destroy()
--Restarting
script.Disabled = true
script.Disabled = false
------------
end)
end)
No clue why you’re sending the script for, and the unequipremote should be outside the equip remote.
Do you mean i should delete the Script found in the :FireServer?
Yeah )()()()()()()()()()()()()()
Actually there is nothing changed.
I know, but I just saved you from doing useless stuff.
But the issue is that you’re using the same cloned model of flashlight, you don’t even create one for each player.
How do i create new one for each player?
Also the Animations play for each player when the remote is fired
You could just clone it when equip and destroy it when unequip. You can use a table to sort this out.
Do you think when i do this when firing the remote every player will also get flashlights and plays the equip animation?
Should i instance a new Remote from the local script so it be local?
Yep, that will work for everybody. no, matte4r of fact, 1 remote is enough for this.
yes you are right i will redo the script with only one remote.
Uhh one last question how actually will i add onserverevent while I don’t know where actually will i instance the remote?
I don’t get what you’re asking.
When am redoing the script as i said i will instance the remote from the local script and then The script i will add to the serverscriptservice will do the function onserverevent ,How actually will i call the remote that was added from the local script?