Okay, so basically this is a code that goes into a textbutton into a introductory startergui in the new game Im developing. It is meant to remove the tools provided by similar buttons under the same parent frame in the case that they were to try to pick multiple "classes", and gain tools from each. Each button has a script that places and objectvalue named "Warrior". "Ranger", or "Mage" directly into the player. The problem is that the if/then statements will either stop working because they don't see the object, or in this case, it will do nothing, with no output. The following script does not work, and has no output in the debugger, which is in the "Warrior" button.
local Robloxian = script.Parent.Parent.Parent.Parent.Parent
local Mage = game.Lighting.Mage local Ranger = game.Lighting.Ranger local Warrior = game.Lighting.Warrior
function onClicked()
if Mage:IsAncestorOf(Robloxian) == true then Robloxian.Backpack:ClearAllChildren() Robloxian.StarterGear:ClearAllChildren() Robloxian.Mage:Remove()
elseif Ranger:IsAncestorOf(Robloxian) == true then
Robloxian.Backpack:ClearAllChildren()
Robloxian.StarterGear:ClearAllChildren()
Robloxian.Ranger:Remove()
else print "Class selected!"
end
end
script.Parent.MouseButton1Click:connect(onClicked)
This other script is more simple, but it doesn't work at all if the player does not have the "Mage" value.
local Robloxian = script.Parent.Parent.Parent.Parent.Parent
function onClicked()
if Robloxian.Mage then Robloxian.Backpack:ClearAllChildren() Robloxian.StarterGear:ClearAllChildren() Robloxian.Mage:Remove()
elseif Robloxian.Warrior then
Robloxian.Backpack:ClearAllChildren()
Robloxian.StarterGear:ClearAllChildren()
Robloxian.Warrior:Remove()
elseif Robloxian.Ranger then
Robloxian.Backpack:ClearAllChildren()
Robloxian.StarterGear:ClearAllChildren()
Robloxian.Ranger:Remove()
end
end
script.Parent.MouseButton1Click:connect(onClicked)
I'd appreciate it if somebody could just explain why the first one isn't working or yielding an output.

1 comment
Sorry about the sloppiness. It's my first time posting here.