So, I have this script located in StarterGui, that whenever you press F it will create a light that acts like a flashlight, inside the RootPart of the player. When you press F again it will dissapear. However, you can only see it on your client. How can I make it serverside?
local inputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local enabled = false
local light
inputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.F then
if not enabled then
light = Instance.new("PointLight", character.HumanoidRootPart)
light.Brightness = 2
light.Name = "TorsoLight"
light.Range = 0
light.Shadows = true
tweenService:Create(light, tweenInfo, {Range = 25}):Play()
game.Workspace.SoundEffects.FlashlightOn:Play()
enabled = true
else
tweenService:Create(light, tweenInfo, {Range = 0}):Play()
game.Workspace.SoundEffects.FlashlightOff:Play()
wait(0.70)
light:Destroy()
enabled = false
end
end
end)

4 comments
Im dont really have experience on RemoteEvents. You think you can help me out?
Create a new "RemoteEvent" object in ReplicatedStorage. Since you are doing Client to server communication, you would put game.ReplicatedStorage.RemoteEvent:FireServer(whatever information you want to fire). On the server side script, do something like game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect() or :Wait(), depending on how you're coding. Everything else is just normal events.
Ok. I will try that tomorrow and I will update you
After a while I got it working, thanks man