Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script is not cloning the gui into the target?

Asked by 8 years ago
Edited 8 years ago
01enabled = true
02function onDamage(Part)
03    if Part.Parent:FindFirstChild("Humanoid") ~= nil and enabled == true and Part.Parent.Name ~= script.Owner.Value then
04        enabled = false
05        script.Disabled = true
06                local enemy = Part.Parent
07        for i = 1,40 do
08        enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
09        wait(0.07)
10        end
11        game.ReplicatedStorage.Genjutsu:Clone().Parent = enemy.PlayerGui -- Gui Part
12    end
13    wait(0.025)
14end
15 
16script.Parent.Touched:connect(onDamage)

This script is a damage script that activates if you are inside a certain big block then this script activates and you should see a gui but it's not working /: please help me .

Thanks for your cooperation!

1 answer

Log in to vote
0
Answered by 8 years ago

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:

01enabled = true
02 
03function onDamage(Part)
04 
05    if Part.Parent:FindFirstChild("Humanoid") ~= nil and enabled == true and Part.Parent.Name ~= script.Owner.Value then
06        enabled = false
07        script.Disabled = true
08 
09        local enemy = Part.Parent
10        local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui --New PlayerGui Variable
11 
12        for i = 1,40 do
13            enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
14            wait(0.07)
15        end
View all 25 lines...

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.

1game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui -- Gui Part      
2 
3for i = 1,40 do
4        enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
5    wait(0.07)
6end

New Script:

01enabled = true
02 
03function onDamage(Part)
04 
05    if Part.Parent:FindFirstChild("Humanoid") ~= nil and enabled == true and Part.Parent.Name ~= script.Owner.Value then
06        enabled = false
07        script.Disabled = true
08 
09        local enemy = Part.Parent
10        local enemyGui = game.Players:GetPlayerFromCharacter(enemy).PlayerGui --New PlayerGui Variable
11 
12        game.ReplicatedStorage.Genjutsu:Clone().Parent = enemyGui -- Gui Part      
13 
14        for i = 1,40 do
15            enemy.Humanoid.Health = enemy.Humanoid.Health - 0.50
View all 25 lines...
0
Thanks for the help , but the method didn't work and it doesn't show in the output problems . DarkWQlfc 20 — 8y
0
I can help you on roblox through the messaging system. iiTylerSoul 56 — 8y
Ad

Answer this question