I have no real experience with either of these so any help is appreciated.
I have created scripts that work if filtering enabled is not on. I now need to rewrite them for filtering enable due to my game being exploited.
Here is what needs to happen in pseudo.
01 | --[[ |
02 | When the player clicks create a new part. |
03 | Set the parts CFrame to the part in the gun called main. |
04 | Give the part a parent. |
05 | Add the part to game service "debris" to be removed after 2 seconds. |
06 | Make the part black. |
07 | Scale the part to the smallest size possible. |
08 | Give the part a velocity. |
09 | When the part hits something check for a humanoid. |
10 | If the part finds a humanoid then get the player from character. |
11 | respawn the player who was hit. |
12 | Add 1 to the shooters kills. |
13 | Add 1 to the deaths of the player shot. |
14 | --]] |
My attempts to do this with filtering enabled respawned the shooter, not the person who was shot.
So, you'll want a remote event to trigger in order to respawn a hit player. You can't do this on the client side (the LocalScript side), so you'll have to use a RemoteEvent object.
On the server, you'll take the RemoteEvent and give it the player respawn logic, like so:
1 | local event = game.ReplicatedStorage.RemoteEvent --replace with wherever the RemoteEvent is |
2 | event.onServerEvent:connect( function (player, toRespawn) |
3 | -- resppawn the player here |
4 | end ) |
Note that fact that you get the player that called the event automatically in the arguments.
On the client, you'll do this:
1 | local event = game.ReplicatedStorage.RemoteEvent --replace with wherever the RemoteEvent is |
2 | --when the person is hit. The variable of the hit player is 'toRespawn' |
3 | event:FireServer(toRespawn) |