Hi, the title say my problem.
Here is the script:
local humanoid = script.Parent:WaitForChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("RemoteEvents")
local location = script.Parent:WaitForChild("Location")
humanoid.HealthChanged:Connect(function(Damage)
script.Parent.BillboardGui.BackGround.Top.Size = UDim2.new(Damage / humanoid.MaxHealth, 0,1,0)
end)
humanoid.Died:Connect(function()
Remotes:WaitForChild("HealthChanged"):FireClient(location)
end)
Anyone can help me?
3YbuKtOp
(Alex_Kornilov)
#2
You need to specify which player you are sending this event to, or use FireAllClients (to send to everyone)
Docs: RemoteEvent | Roblox Creator Documentation
Example:
Remotes:WaitForChild("HealthChanged"):FireClient(game.Players:GetPlayerFromCharacter(script.Parent), location)
game.Players:GetPlayerFromCharacter(script.Parent)
- Player Object, if script.Parent
is Player Character
Im in a server script how can i specify the player?
3YbuKtOp
(Alex_Kornilov)
#4
Player - game.Players:GetPlayerFromCharacter(script.Parent)
if script.Parent
is Player Character
OR
Player - game.Players["PlayerName"]
I tried this but it gives me the same error
game.Players.PlayerAdded:Connect(function(player)
humanoid.Died:Connect(function(plr)
Remotes:WaitForChild("HealthChanged"):FireClient(game.Players:GetPlayerFromCharacter(game.Players[player.Name]) ,location)
end)
end)
3YbuKtOp
(Alex_Kornilov)
#6
you misunderstood, you must use one and fire to Player Object (now this is player
)
game.Players.PlayerAdded:Connect(function(player)
humanoid.Died:Connect(function(plr)
Remotes:WaitForChild("HealthChanged"):FireClient(player, location)
end)
end)
1 Like
Thank and sorry for the misunderstood
system
(system)
Closed
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.