I have a flashlight script that works, thanks to a few things from the DevForum. But when I tested it out on my game, I noticed how the light from both the Client and Server side seemed off.
Here are the scripts too, courtesy from the DevForum:
--SERVER SCRIPT
EquipFlash.OnServerEvent:Connect(function()
if not hasFlashlight then
hasFlashlight = true
local Character = Player.Character or Player.CharacterAdded:Wait()
Flashlight = ReplicatedStorage.Handle:Clone()
Flashlight.Parent = Character
local Motor6D = Instance.new("Motor6D")
Motor6D.Parent = Character
Motor6D.Part0 = Character:FindFirstChild("Right Arm")
Motor6D.Part1 = Flashlight
LoadedAnim1:Play()
task.wait(LoadedAnim1.Length * 0.925)
LoadedAnim1:AdjustSpeed(0)
else
LoadedAnim1:AdjustSpeed(-1)
task.wait(LoadedAnim1.Length * 0.925)
LoadedAnim1:Stop()
Motor6D = Player.Character:FindFirstChild("Motor6D")
Motor6D:Destroy()
Flashlight:Destroy()
Flashlight = nil
hasFlashlight = false
end
end)
--CLIENT SIDE
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EquipFlash = ReplicatedStorage.EquipFlash
local debounce = true
UserInputService.InputBegan:Connect(function(key)
if key.UserInputType == Enum.UserInputType.Keyboard then
if key.KeyCode == Enum.KeyCode.F then
if debounce then
debounce = false
EquipFlash:FireServer()
task.wait(.95)
debounce = true
end
end
end
end)
What have I done wrong, and what can I do to improve/fix it?