What I want to do here.
Trying to make something close to the Deep Rock Galactic flare system.
Why don’t i just fix it myself?
Can’t seem to get the script to work on the serverside.
What I’ve tried.
I’ve tried to use RemoteEvents, but I’m just not that good with using them.
I’m aware the script is a mess, no need to point it out.
local Flare = game.ReplicatedStorage.Equipment.Flare
local Mouse = game.Players.LocalPlayer:GetMouse()
local Player = game.Players.LocalPlayer
local Attachment = Instance.new("Attachment", Flare)
local HRP = Player.Character.HumanoidRootPart
local myDebounce = true
repeat
wait()
until Player.Character
Mouser = Player:GetMouse()
name = Player.Name
char = game.Workspace[Player.Name]
Mouser.KeyDown:connect(function(key)
if key == "f" then
local Clone = Flare:Clone()
if myDebounce == true then
myDebounce = false
Clone.Parent = game.Workspace
Clone.Position = HRP.CFrame * Vector3.new(0,0,-3)
local direction = Mouse.Hit.LookVector
local forceMultipliter = 30
Clone:ApplyImpulse(direction * forceMultipliter)
wait(6)
myDebounce = true
wait(20)
Clone:Destroy()
end
end
end)
if myDebounce == true then
myDebounce = false
Clone.Parent = game.Workspace
Clone.Position = HRP.CFrame * Vector3.new(0,0,-3)
local direction = Mouse.Hit.LookVector
local forceMultipliter = 30
Clone:ApplyImpulse(direction * forceMultipliter)
wait(6)
myDebounce = true
wait(20)
Clone:Destroy()
end
When you fire a remote event, it just triggers an event on the server, exactly how a KeyDown event works, except you can pass extra arguments. The signature of FireServer is: FireServer(...)
The . . . means any number of extra arguments, which will be unpacked at the event handler:
myRemoteEvent.OnServerEvent:Connect(function(arg1, arg2)
--Put server code here
end)
You should one argument to pass the HRP.CFrame. Your remote event object just needs to be in a location visible to both the client and server, such as the workspace or ReplicatedStorage.
local Flare = game.ReplicatedStorage.Equipment.Flare
local Mouse = game.Players.LocalPlayer:GetMouse()
local Player = game.Players.LocalPlayer
local Attachment = Instance.new("Attachment", Flare)
local HRP = Player.Character.HumanoidRootPart
local myDebounce = true
local myRemoteEvent = game.ReplicatedStorage.ExampleForTheFlaresOrSomething
repeat
wait()
until Player.Character
Mouser = Player:GetMouse()
name = Player.Name
char = game.Workspace[Player.Name]
Mouser.KeyDown:connect(function(key)
if key == "f" then
local Clone = Flare:Clone()
Clone.Name = "Clone"
myRemoteEvent:FireServer(HRP.CFrame)
end
end)
And the server script.
local myRemoteEvent = game.ReplicatedStorage.ExampleForTheFlaresOrSomething
myRemoteEvent.OnServerEvent:Connect(function(CFrame)
if myDebounce == true then
myDebounce = false
Clone.Parent = game.Workspace
Clone.Position = HRP.CFrame * Vector3.new(0,0,-3)
local direction = Mouse.Hit.LookVector
local forceMultipliter = 30
Clone:ApplyImpulse(direction * forceMultipliter)
wait(6)
myDebounce = true
wait(20)
Clone:Destroy()
end
end)
I’m probably missing something here that should be easy to understand, sorry bout that.