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:
enabled = true
function onDamage(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and enabled == true and Part.Parent.Name ~= script.Owner.Value then
enabled = false
script.Disabled = true
local enemy = Part.Parent
local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui
for i = 1,40 do
enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
wait(0.07)
end
game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui
end
wait(0.025)
end
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.
game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui
for i = 1,40 do
enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
wait(0.07)
end
New Script:
enabled = true
function onDamage(Part)
if Part.Parent:FindFirstChild("Humanoid") ~= nil and enabled == true and Part.Parent.Name ~= script.Owner.Value then
enabled = false
script.Disabled = true
local enemy = Part.Parent
local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui
game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui
for i = 1,40 do
enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
wait(0.07)
end
end
wait(0.025)
end
script.Parent.Touched:connect(onDamage)
2 comments
Thanks for the help , but the method didn't work and it doesn't show in the output problems .
I can help you on roblox through the messaging system.