Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Cloning a gui to a player under certain conditions?

I have this localscript inside a sword, and there's a part that's not working. The output gives no error message at all. Please help. The specific part that has a problem is supposed to make a gui that is in the sword be cloned to the player that activated it.

local Tool = script.Parent;

enabled = true
function onButton1Down(mouse)
if not enabled then
return
end

enabled = false
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"

wait(.5)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
enabled = true

end

function onEquippedLocal(mouse)

if mouse == nil then
print("Mouse not found")
return 
end

--This part is the problem

player = game.Players.LocalPlayer
if script.Parent.Parent.Ability1name ~= "Swords" and script.Parent.Parent.Ability2name ~= "Swords" and script.Parent.Parent.Ability3name ~= "Swords" and player.PlayerGui:FindFirstChild("Train") == false then
script.Parent.Train:Clone().Parent = player.PlayerGui
end

mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end


Tool.Equipped:connect(onEquippedLocal)

2 answers

✓ Accepted answer

(line 28) 'Ability1name' - 'Ability3name'. You're reading an Instance.

If these are StringValues, do

Ability1name.Value ~= "Sword"

If in doubt, put a bunch of Prints in, see what's passing and what's not.

2 comments

0

Thanks so much!

0

Welcome

The way that you've done it is not the most efficient way. Let me give it a try. I'd like to first apologize for lack of spacing due to my Studio updating.

player = game.Players.LocalPlayer -- This better be a local script..
if not script.Parent.Parent.Ability1name == "Swords" and not script.Parent.Parent.Ability2name == "Swords" and not scipr.Parent.Parent.Ability3name == "Swords" and not player.PlayerGui:FindFirstChild("Train") then
script.Parent.Train:clone().Parent = player.PlayerGui
end

This discussion is preserved as it was. New answers, comments, and votes are closed.