MouseButton1Click is not working. Please help. I do not know what the problem is. Anyone?
I am trying to make an equip system. Specifacally, for pets. The MouseButton1Click
event is not working. Please help.
This is the script
01 | local function createFrame(name, equippedValue) |
02 | local clone = temp:Clone() |
04 | if game.ReplicatedStorage.Pets:FindFirstChild(name) then |
05 | local VPFObj = game.ReplicatedStorage.Pets [ name ] :Clone() |
08 | local fakeCam = Instance.new( "Camera" ) |
09 | fakeCam.Name = "FakeCam" |
10 | fakeCam.CFrame = CFrame.new(VPFObj.PrimaryPart.Position + (VPFObj.PrimaryPart.CFrame.lookVector * 5 ), VPFObj.PrimaryPart.Position) |
12 | clone.CurrentCamera = fakeCam |
14 | clone.PetName.Text = name |
16 | if equippedValue = = "Equipped" then |
17 | clone.Equipped.Text = "Equipped" |
18 | clone.Equip.Text = "Equipped" |
19 | clone.Equipped.TextColor 3 = Color 3. fromRGB( 105 , 247 , 98 ) |
20 | elseif equippedValue = = "Unequipped" then |
21 | clone.Equipped.Text = "Unequipped" |
22 | clone.Equip.Text = "Unequipped" |
23 | clone.Equipped.TextColor 3 = Color 3. fromRGB( 247 , 58 , 58 ) |
26 | clone.Parent = script.Parent.Pets |
28 | print (clone.Parent.Name) |
39 | local stringValues = game.ReplicatedStorage [ folderName ] .PetsInventory:GetChildren() |
40 | if #stringValues > 0 then |
41 | for _, value in pairs (stringValues) do |
42 | if value:IsA( "StringValue" ) and game.ReplicatedStorage.Pets:FindFirstChild(value.Name) then |
43 | if game.ReplicatedStorage [ folderName ] .EquippedPet.Value = = value.Name then |
44 | newFrame = createFrame(value.Name, "Equipped" ) |
46 | newFrame = createFrame(value.Name, "Unequipped" ) |
54 | game.ReplicatedStorage.CreatePetFrame.OnClientEvent:Connect( function (name) |
55 | currentNewFrame = createFrame(name, "Unequipped" ) |
58 | repeat wait() until currentNewFrame ~ = nil and newFrame ~ = nil |
60 | currentNewFrame:FindFirstChild( "Equip" ).MouseButton 1 Click:Connect( function () |
62 | local otherCloneFrames = script.Parent.Pets:GetChildren() |
63 | if #otherCloneFrames > 0 then |
64 | for _, clone in pairs (otherCloneFrames) do |
65 | if not clone:IsA( "UIGridLayout" ) then |
66 | clone.Equipped.Text = "Unequipped" |
67 | clone.Equip.Text = "Unequipped" |
68 | clone.Equipped.TextColor 3 = Color 3. fromRGB( 247 , 58 , 58 ) |
72 | print ( "Got to this line" ) |
73 | currentNewFrame.Equipped.Text = "Equipped" |
74 | currentNewFrame.Equip.Text = "Equipped" |
75 | currentNewFrame.Equipped.TextColor 3 = Color 3. fromRGB( 105 , 247 , 98 ) |
76 | game.ReplicatedStorage [ folderName ] .EquippedPet.Value = currentNewFrame.Name |
77 | print ( "Changed Value to " ..(game.ReplicatedStorage [ folderName ] .EquippedPet.Value)) |
80 | newFrame:FindFirstChild( "Equip" ).MouseButton 1 Click:Connect( function () |
81 | local otherCloneFrames = script.Parent.Pets:GetChildren() |
82 | if #otherCloneFrames > 0 then |
83 | for _, clone in pairs (otherCloneFrames) do |
84 | if not clone:IsA( "UIGridLayout" ) then |
85 | clone.Equipped.Text = "Unequipped" |
86 | clone.Equip.Text = "Unequipped" |
87 | clone.Equipped.TextColor 3 = Color 3. fromRGB( 247 , 58 , 58 ) |
91 | print ( "Got this line" ) |
92 | newFrame.Equipped.Text = "Equipped" |
93 | newFrame.Equip.Text = "Equipped" |
94 | newFrame.Equipped.TextColor 3 = Color 3. fromRGB( 105 , 247 , 98 ) |
95 | game.ReplicatedStorage [ folderName ] .EquippedPet.Value = newFrame.Name |
There are no errors. Nothing.