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

Gui still showing even though it shouldn't?

Asked by 2 years ago

So, I'm making a katana have an ability and when you press e it will sort of slice through the player. I made it so a gui shows as well to show whats happening, sort of like a flash. Anyways, when I use it on a player it works fine, but for an npc, since its not a player the playergui won't work, but even though I put an if statement saying if the name of it is equal to so and so, it still goes through with the script even if the name of the npc is listed on there. Help would be appreciated!

Here is the script in serverscript service which gets activated when a remote gets fired.

sword.Handle.Hitbox.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            if debounce == false then
                debounce = true
                if hit.Parent.Humanoid.Health <= 30 then
                    touched = true
                    hit.Parent.Humanoid:TakeDamage(30)
                    sword.Handle.BigSlash:Play()
                    hit.Parent.HumanoidRootPart.Anchored = true
                    char.Humanoid.WalkSpeed = 0
                    wait()
                    char.HumanoidRootPart.Anchored = true
                    if hit.Parent.Name ~= "Cartoon" or "Cartoon2" or "Noob" or "Dummy" then
                        local hitplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.9
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.8
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.7
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.6
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.5
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.4
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.3
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.2
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.1
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0
                        char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
                        char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(offset)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.2
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.3
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.4
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.5
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.6
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.7
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.8
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.9
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 1
                    end
                    char.Humanoid.WalkSpeed = 20
                    wait()
                    char.HumanoidRootPart.Anchored = false
                        hit.Parent.HumanoidRootPart.Anchored = false
                else
                    hit.Parent.HumanoidRootPart.Anchored = true
                    char.Humanoid.WalkSpeed = 0
                    wait()
                    char.HumanoidRootPart.Anchored = true
                    touched = true
                    debounce = true
                    hit.Parent.Humanoid:TakeDamage(40)
                    sword.Handle.BigSlash:Play()
                    if hit.Parent.Name ~= "Cartoon" or "Cartoon2" or "Noob" or "Dummy" then
                        print(hit.Parent.Name)
                        local hitplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.9
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.8
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.7
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.6
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.5
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.4
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.3
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.2
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.1
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0
                        char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
                        char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(offset)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.2
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.3
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.4
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.5
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.6
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.7
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.8
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 0.9
                        wait(0.05)
                        hitplayer.PlayerGui.KatanaThingy.Frame.Transparency = 1
                    end
                    char.Humanoid.WalkSpeed = 20
                    wait()
                    char.HumanoidRootPart.Anchored = false
                    hit.Parent.HumanoidRootPart.Anchored = false
        end
            end
        end
    end)
    wait(2)
    if touched == false then
        debounce = true
    end
end)

sorry the script is like that,i dont know why.

1 answer

Log in to vote
1
Answered by 2 years ago

replace:

if hit.Parent.Name ~= "Cartoon" or "Cartoon2" or "Noob" or "Dummy" then

with:

if game.Players:GetPlayerFromCharacter(hit.Parent)then

or

if hit.Parent.Name ~= "Cartoon" and hit.Parent.Name ~="Cartoon2" and hit.Parent.Name ~="Noob" and hit.Parent.Name ~="Dummy"  then
0
OHHH, I'm stupid i forgot I have to repeat the statement each time I say "or" thank you so much! DriBowser 55 — 2y
Ad

Answer this question