Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

FPS FE Player Damage help?

Asked by 6 years ago

So I am working on a fps game. The game is FE is on and I'm not very familiar with FE. The problem is that when I shoot the weapon and it kills a player it only shows on the Client who killed the player. I have looked at the Roblox Wiki, Youtube videos and some articles about filtering enabled but all of my attempts never work.

Here's what I know: I will probably need a remote event to show all clients that the player took damage/died. I'll also need a script that handles the event when needed.

What should I do?

(Here's part of the framework)

local damage = 30

if hit.Parent:findFirstChild("Humanoid") then
    hit.Parent:findFirstChild("Humanoid"):TakeDamage(damage)

    -- Something like this?
    -- The first argument is the players name that was hit
    -- The second argument is the damage done
    game.ReplicatedStorage.KillEvent:FireServer(hit.Parent.Name,damage)
end
0
Well you shouldn't be handling the damaging on the client like you're doing.! User#19524 175 — 6y
0
If this is in a local script, it probs would not show on the server. So you need to use another remote event to deduct damage from the player being hit and then in serverscriptservice add a global script which does the stuff in lines 01-08 which runs after the aforementioned damage deducting remoteevent is fired oggy521 72 — 6y
0
Can I use a module function to do it? sen_trix 31 — 6y

2 answers

Log in to vote
0
Answered by
oggy521 72
6 years ago

If I wasn't clear enough, then here's basically an example you can do. In RepStorage, add the remote event called "DamageEvent" and then in ServerScriptService add a global script.

In the global script, write the following:

`local damage = 30

game.ReplicatedStorage.DamageEvent.Fired:Connect(function(hit,damage)
if hit.Parent:findFirstChild("Humanoid") then
    hit.Parent:findFirstChild("Humanoid"):TakeDamage(damage)

  --AND all the other stuff you have in the local script

end
end)

`

And then in your local script, change it to

game.ReplicatedStorage.DamageEvent:FireServer(hit,damage)

0
I tested it in a local server but It didn't work. There were no errors anywhere though sen_trix 31 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Oggy forgot to identify the player firing the event in the global script:

game.ReplicatedStorage.DamageEvent.Fired:Connect(function(player, hit, damage) -- the first argument is always the player who fired the remote
if hit.Parent:findFirstChild("Humanoid") then
    hit.Parent:findFirstChild("Humanoid"):TakeDamage(damage)

  --AND all the other stuff you have in the local script

end
end)
0
btw, no need to accept my answer accept oggy's awesomeipod 607 — 6y
0
kay sen_trix 31 — 6y

Answer this question