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

BillboardGui not working?

Asked by 8 years ago

These are local scripts located within the billboard guis themselves. I'm new to scripting bgs so I don't really know all that much and I might be doing somethin wrong.

No errors are being thrown:

script.Parent.MouseButton1Down:connect(function(hit)
    hair = hit:WaitForChild('CharacterCreation'):WaitForChild('Hair'):WaitForChild('1stHairValue')
    hair.Value = hair.Value - 1     
end)
script.Parent.Parent.MouseEnter:connect(function()
    script.Parent.ImageColor3 = Color3.new(182/255, 182/255, 182/255)
    script.Parent.Size = UDim2.new(1.1, 0, 1.1, 0)
    script.Parent.Position = UDim2.new(-.1, 0, -.1, 0)

end)
script.Parent.Parent.MouseLeave:connect(function()
    script.Parent.ImageColor3 = Color3.new(1, 1, 1)
    script.Parent.Size = UDim2.new(1.1, 0, 1.1, 0)
    script.Parent.Position = UDim2.new(-.1, 0, -.1, 0)
end)

Hopefully you can understand what I'm doing, if not lemme explain. I'm making a 3D Character Customization that uses Parts will Billboard Guis on them. When you click the button, a number is added to your Hair value, which then changes your hair.

0
Use print() to see where the code is not working legosweat 334 — 8y
0
I put one at the mouseclicked area, and it didn't print. Nothing is happening at all, it seems as if the script is disabled. xxxXMrsAwesomeXxxx 70 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

There are a few problems so let me try to help. The First error I see is that you seem to think MouseButton1Down returns the character. This is wrong. MouseButton1Down returns the mouse position which will not be helping us in what we're trying to do. So the first thing to do would be to get the character. Because this is in a Local Script,(Like it should be), we can get the character from the player using plr.Character we first have to define the player. This is easy. When using local script we can use game.Players.LocalPlayer to get the Local player. After we get the player we can then get the Character and use that instead of hit.

local plr = game.Players.LocalPlayer-- This gets the local player 

script.Parent.MouseButton1Down:connect(function(mouse)-- this could be left blank as it's not needed but for reference here it is
    local character = plr.Character-- this gets the Player's character
    hair = character:WaitForChild('CharacterCreation'):WaitForChild('Hair'):WaitForChild('1stHairValue')-- if these variables are inside the player use plr instead of character
    hair.Value = hair.Value - 1     
end)
script.Parent.Parent.MouseEnter:connect(function()
    script.Parent.ImageColor3 = Color3.new(182/255, 182/255, 182/255)
    script.Parent.Size = UDim2.new(1.1, 0, 1.1, 0)
    script.Parent.Position = UDim2.new(-.1, 0, -.1, 0)

end)
script.Parent.Parent.MouseLeave:connect(function()
    script.Parent.ImageColor3 = Color3.new(1, 1, 1)
    script.Parent.Size = UDim2.new(1.1, 0, 1.1, 0)
    script.Parent.Position = UDim2.new(-.1, 0, -.1, 0)
end)

Hope that helped! Good luck!

0
Didn't work ;( xxxXMrsAwesomeXxxx 70 — 8y
Ad
Log in to vote
-2
Answered by 8 years ago

In my opinion, right from the beginning, it's incorrect.

1.

script.Parent.MouseButton1Down:connect(function(hit)

In this bit (above), the "hit" argument is not needed. This argument is only used in "Touched" events, where character touches a specific brick to execute a script.

SOLUTION:

script.Parent.MouseButton1Down:connect(function()

2.

        hair = hit:WaitForChild('CharacterCreation'):WaitForChild('Hair'):WaitForChild('1stHairValue')

    hair.Value = hair.Value - 1

I couldn't understand this bit (above). First of all, the errors are most likely to come from this part here. You can't use "WaitForChild" like that. Computer gets confused and stops on this spot, and doesn't continue further. Alot of syntax mistakes aswell, so I'll only fix those, since I don't know any of these variables (what are you linking them towards). Also, you can't go into negative numbers in LUA, as far as I know. They won't work. Use positive ones instead!

SOLUTION:

hair = hit:WaitForChild('CharacterCreation')
hair1 = hit:WaitForChild('Hair')
hair2 = hit:WaitForChild('1stHairValue')

Also, be sure to check Output (You can enable it by going to "View" tab and clicking on "Output". To know if it's open, the selection's background should be dark grey.) to understand the problem. Output is the key to solving scripting problems in ROBLOX, since it gives you all errors, and syntax problems you've done.

Hope this helps! Good luck in scripting!

1
You're so wrong xD Nothing you have explained was actually right. I know you're trying to help but you don't seem to know what you're talking about. User#11440 120 — 8y
0
Actually you can use WaitForChild in the way I did, it works efficiently, rather then defining over and over again. xxxXMrsAwesomeXxxx 70 — 8y

Answer this question