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

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

Asked by 10 years ago

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 ;(

0
Full respect for posting an attempt, that will get you alot further with programming. RaverKiller 668 — 10y

6 answers

Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
10 years ago

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)
Ad
Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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?

Log in to vote
0
Answered by 10 years ago

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

Log in to vote
0
Answered by 10 years ago
-- 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

Log in to vote
0
Answered by 10 years ago

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.

Log in to vote
0
Answered by 10 years ago
script.Parent.MouseButton1Down:connect(function()
game.Workspace.Part.Smoke.Color = "" --Color there
game.Players.LocalPlayer.PlayerGui.Smokec.Frame --Setting Here
end)

Answer this question