Im trying to send a remote event to the client when someone is killed but how do I get the local player when it happens?
local Bullet = script.Parent
local NearbyBulletSound = Bullet:WaitForChild('NearbyBulletSound')
local Players = game:GetService("Players")
local player = Players.. --What do i put here?
local Damage = Bullet:WaitForChild("Damage")
local Damaged = false
Bullet.Touched:Connect(function(hit)
local CharHum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hit and CharHum and CharHum.Health > 0 then
game.SoundService.DingSound:Play()
player.folder.lastkilled.Value = hit.Parent.Name
game.ReplicatedStorage.Killed:FireClient(player)
CharHum.Health = CharHum.Health - Damage.Value
NearbyBulletSound:Play()
end
wait(0.1)
Bullet:Destroy()
end)
while wait(1.5) do
Bullet:Destroy()
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
I think you mean the player that died and not the local player. The local player is only available on the client. But you can connect to the humanoid died event and send your event to the client there. Humanoid | Documentation - Roblox Creator Hub
Well, you can attach the name or userid or a reference of the player who fired the bullet to the bullet. Then in your script you can pull out the info and send it in a remote event to the client to pop up the gui to the correct player
Where you prepare the bullet you can add an attribute called owner withe the userid of the player then in the script above you can read the owner from the bullet. Instance | Documentation - Roblox Creator Hub