Hello there, DarkWqlfc. lol
The reason your gui isn't cloning into the enemy is that you can't access the PlayerGui from the character.
Your enemy variable is a character.
To get the player from the character, use the :GetPlayerFromCharacter function.
Example: game.Players:GetPlayerFromCharacter(character)
Anyways, to fix your problem, I would make another variable for the PlayerGui:
03 | function onDamage(Part) |
05 | if Part.Parent:FindFirstChild( "Humanoid" ) ~ = nil and enabled = = true and Part.Parent.Name ~ = script.Owner.Value then |
07 | script.Disabled = true |
09 | local enemy = Part.Parent |
10 | local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui |
13 | enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50 |
17 | game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui |
25 | script.Parent.Touched:connect(onDamage) |
Playing around with this script, I noticed that the gui only pops up after damage is taken.
You might not want this.
To make it where the gui pops up while the damage is taken, clone the gui before the damage loop.
1 | game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui |
4 | enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50 |
New Script:
03 | function onDamage(Part) |
05 | if Part.Parent:FindFirstChild( "Humanoid" ) ~ = nil and enabled = = true and Part.Parent.Name ~ = script.Owner.Value then |
07 | script.Disabled = true |
09 | local enemy = Part.Parent |
10 | local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui |
12 | game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui |
15 | enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50 |
25 | script.Parent.Touched:connect(onDamage) |