I'm trying to make a character select gui for an upcoming project of mine, but everytime I try to use one of the click functions, it doesn't work.
This is the script I originally had on my morph block:
And here it is for the gui:
--Put the Directory for the Morph Here-- local localmorph = game.ReplicatedStorage["Mario"] local debounce = false ChestPos = CFrame.new(0,0,0) LeftArmPos = CFrame.new(0,-0.40,0) RightArmPos = CFrame.new(0,-0.40,0) LeftLegPos = CFrame.new(0,0.10,0) RightLegPos = CFrame.new(0,0.10,0) --Group Arms 1-2, Chest, and Legs 1-2 into a model, paste it into the server storage, then --change the name above to coorespond with the model. (See Primid in ServerStorage for example)-- --im sorry this is so sloppy D: --whoever made this should be sorry ~SFOH -- ^^^^^^ function onClicked(hit) if hit.Parent:findFirstChild("Humanoid") and debounce == false then wait(.01) debounce = true if hit.Parent:findFirstChild("Torso") ~= nil then --SAMUS GLITCH FIX -- you're welcome! ~SFOH hit.Parent:findFirstChild("Torso").Anchored = true if hit.Parent.Torso:FindFirstChild("Left Shoulder") and hit.Parent.Torso:FindFirstChild("Left Hip") and hit.Parent.Torso:FindFirstChild("Right Hip") and hit.Parent.Torso:FindFirstChild("Right Shoulder") then local ls,rs,lh,rh=hit.Parent.Torso["Left Shoulder"],hit.Parent.Torso["Right Shoulder"],hit.Parent.Torso["Left Hip"],hit.Parent.Torso["Right Hip"] ls.C0=CFrame.new(-1,.5,0)*CFrame.Angles(0,-math.pi/2,0) ls.C1=CFrame.new(.5,.5,0)*CFrame.Angles(0,-math.pi/2,0) rs.C0=CFrame.new(1,.5,0)*CFrame.Angles(0,math.pi/2,0) rs.C1=CFrame.new(-.5,.5,0)*CFrame.Angles(0,math.pi/2,0) lh.C0=CFrame.new(-1,-1,0)*CFrame.Angles(0,-math.pi/2,0) lh.C1=CFrame.new(-.5,1,0)*CFrame.Angles(0,-math.pi/2,0) rh.C0=CFrame.new(1,-1,0)*CFrame.Angles(0,math.pi/2,0) rh.C1=CFrame.new(0.5,1,0)*CFrame.Angles(0,math.pi/2,0) end ----------------------- end --destroy previous morph if found-- if hit.Parent:findFirstChild("Arm1") ~= anil then hit.Parent:findFirstChild("Arm1"):Destroy() end wait(.01) if hit.Parent:findFirstChild("Arm2") ~= nil then hit.Parent:findFirstChild("Arm2"):Destroy() end wait(.01) if hit.Parent:findFirstChild("Leg1") ~= nil then hit.Parent:findFirstChild("Leg1"):Destroy() end wait(.01) if hit.Parent:findFirstChild("Leg2") ~= nil then hit.Parent:findFirstChild("Leg2"):Destroy() end wait(.01) if hit.Parent:findFirstChild("Chest") ~= nil then hit.Parent:findFirstChild("Chest"):Destroy() end wait() --morph stuff-- if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Arm1") == nil and hit.Parent:FindFirstChild("Torso") and hit.Parent.Torso:FindFirstChild("Left Shoulder") then local g = localmorph.Arm1:clone() hit.Parent.Torso["Left Shoulder"].C0=hit.Parent.Torso["Left Shoulder"].C0*LeftArmPos g.Parent = hit.Parent local C = g:GetChildren() for i=1, #C do if C[i]:IsA("BasePart") then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent["Left Arm"] Y.Part1 = g.Middle Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false end end if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Arm2") == nil and hit.Parent:FindFirstChild("Torso") and hit.Parent.Torso:FindFirstChild("Right Shoulder") then local g = localmorph.Arm2:clone() hit.Parent.Torso["Right Shoulder"].C0=hit.Parent.Torso["Right Shoulder"].C0*RightArmPos g.Parent = hit.Parent local C = g:GetChildren() for i=1, #C do if C[i]:IsA("BasePart") then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent["Right Arm"] Y.Part1 = g.Middle Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false end if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") == nil then local g = localmorph.Chest:clone() g.Parent = hit.Parent local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent.Torso Y.Part1 = g.Middle Y.C0 = ChestPos Y.Parent = Y.Part0 end for i=1, #C do if C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent.Torso Y.Part1 = g.Middle Y.C0 = ChestPos Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg1") == nil and hit.Parent:FindFirstChild("Torso") and hit.Parent.Torso:FindFirstChild("Left Hip") then local g = localmorph.Leg1:clone() hit.Parent.Torso["Left Hip"].C0=hit.Parent.Torso["Left Hip"].C0*LeftLegPos g.Parent = hit.Parent local C = g:GetChildren() for i=1, #C do if C[i]:IsA("BasePart") then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent["Left Leg"] Y.Part1 = g.Middle Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false end end if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Leg2") == nil and hit.Parent:FindFirstChild("Torso") and hit.Parent.Torso:FindFirstChild("Right Hip") then local g = localmorph.Leg2:clone() hit.Parent.Torso["Right Hip"].C0=hit.Parent.Torso["Right Hip"].C0*RightLegPos g.Parent = hit.Parent local C = g:GetChildren() for i=1, #C do if C[i]:IsA("BasePart") then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Parent["Right Leg"] Y.Part1 = g.Middle Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false end --removing excess stuff- local d = hit.Parent:GetChildren() for i=1, #d do if (d[i].className == "Hat") then d[i]:Destroy() end end if hit.Parent:findFirstChild("Head"):findFirstChild("face").Texture == nil then return end hit.Parent:findFirstChild("Head"):findFirstChild("face").Texture="717dea9c5a1659640155f77c84892c " end end end hit.Parent:findFirstChild("Head").Transparency = 1 hit.Parent:findFirstChild("Left Arm").Transparency = 1 hit.Parent:findFirstChild("Right Arm").Transparency = 1 hit.Parent:findFirstChild("Torso").Transparency = 1 hit.Parent:findFirstChild("Torso").Anchored = false hit.Parent:findFirstChild("Left Leg").Transparency = 1 hit.Parent:findFirstChild("Right Leg").Transparency = 1 wait(1) debounce = false end end debounce=false--this script is total shite ~SFOH end script.Parent.MouseButton1Click:connect(onClicked)
Any help would be greatly appreciated
Well I'm not sure if this is what you're talking about but mousebuttononeclicks would help.
script.Parent.MouseButton1Click:connect(function() print("We have a script.parent which is calling the upper class above us, in this case for this") print("line of code I have a localscript inside of TextButton so parent is TxtButton") print("And the .MouseButton1Click is the event so on clicked event it connects our function") print("And inside of here we can put anything we want it to do. For example, if I click the button") print("It will execute the strings and it will print out what I'm writing right now to you") print("Your welcome if this helped. (I know I can do multilines of strings but im lazy.") end)
I usually use MouseButton1Down and it works. Also, make sure that this script is in a text button on your GUI.
script.Parent.MouseButton1Down:connect(function() end)
So go to line 265 and change it to
script.Parent.MouseButton1Down:connect(onClicked)
Hope this helps.