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

How would you fix this to make it work when I click a button in a gui?

It's mainly for a smoke gui that changes a smoke parent in a brick in workspace?

function onMouseDown1()
wait(2)
script.Parent.Parent.Parent.Workspace.Part.Smoke.Color = game.Startergui.smokec.frame.colors["really red"].value

I dont know what's wrong ;(

1 comment

0

Full respect for posting an attempt, that will get you alot further with programming.

6 answers

✓ Accepted answer

Okay, your missing connection line, and your color needs to be a color3 value, and a lot of this is screwed up in general.

script.Parent.MouseButton1Down:connect(function()
	wait(2)
	game.Workspace.Part.Smoke.Color = BrickColor.new("Really red").Color
end)

Case matters in the names of things. It's StarterGui not Startergui, Value not value.

Also, the script.Parent.Parent.Parent.Workspace... is bad. Don't do that! Like script, you have the reference Workspace already.

Workspace.Part.Smoke.Color = is sufficient and sensitive to fewer things and therefore better!.

Since you've made that mistake your other objects names might not match this capitalization. Standard ROBLOX practice is to capitalize all words in object names, so they really ought to be SmokeC, Frame, Colors, etc.

I'm assuming you simply didn't copy the connection of this script and end of this function?

You are missing an end keyword to end your function block.

-- Assign the button to a variable named "Button" 
Button.MouseButton1Down:connect(function(X, Y)
wait(2)
  script.Parent.Parent.Parent.Workspace.Part.Smoke.Color = game.StarterGui.smokec.frame.colors["really red"].Value
end)

Just so you know, "smoke" is spelled wrong

When I write this, I'm assuming the part is the parent of the script, and the other part is not the part with the script in it.

script.Parent.MouseClick:connect(function()
	wait(2)
	script.Parent.Parent.Parent.Workspace.Part.Smoke.Color  = Color3.new(255,0,0)
end)

To change it back, change the color3.

script.Parent.MouseButton1Down:connect(function()
game.Workspace.Part.Smoke.Color = "" --Color there
game.Players.LocalPlayer.PlayerGui.Smokec.Frame --Setting Here
end)

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