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

Coding script to remove specific parts; script line is not doing anything, not getting error either?

Asked by 3 years ago

This is the line of code that doesnt work:

if e[i].creator.Value == player then
    print("Works")
end

I'm not recieving an error so I'm really not sure what's going wrong, I've tried changing 'player' to 'player.Name' but that didn't work either.

Here is the rest of the code for context:

player = game.Players.LocalPlayer
PathTool = script.Parent
mouse = player:GetMouse()

function Clean()
    print(player)
    e = game.Workspace:GetChildren()
    for i = 1, #e do
        if e[i].className == "Part" then
            if e[i].Name == "PathPlatform" then
                if e[i]:findFirstChild("creator") ~= nil then
                    if e[i].creator.Value == player then
                        print("Works")
                    end
                end
            end
        end
    end
end

mouse.KeyDown:connect(function(key)
    if key:byte() == 114 then
        Clean()
    end
end)

Any help would be greatly appreciated, I've tested the script and every line works except for 'if e[i].creator.Value == player then' - no error message in my Output either!

(Also I should add that the value of the Part.creator.Value is equal to the player's name)

1 answer

Log in to vote
0
Answered by
Dauhxe 0
3 years ago
if e[i].creator.Value == player.Name then                           
    print("Works")                     
end
Ad

Answer this question