generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Head color

Previous Thread :: Next Thread 
astrosyedst is not online. astrosyedst
Joined: 19 Oct 2012
Total Posts: 458
30 Nov 2014 11:15 PM
why this not working?

sp = script.Parent
pla = game.Players.LocalPlayer
char = pla.Character

sp.MouseButton1Click:connect()
char.Head.BrickColor = BrickColor.new("Reddish brown")
wait()
Report Abuse
astrosyedst is not online. astrosyedst
Joined: 19 Oct 2012
Total Posts: 458
30 Nov 2014 11:21 PM
pls someone
Report Abuse
darknightofVorhan is not online. darknightofVorhan
Joined: 23 Jun 2008
Total Posts: 667
30 Nov 2014 11:23 PM
Because you are not connecting a function to the click event. A function to be called when the event occurs needs to be placed between the (). In this case you can just wait until the event happens once, instead of calling a function every time it happens. This is done like so:

local parent = script.Parent
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()

parent.MouseButton1Click:wait()
char.Head.BrickColor = BrickColor.new("Reddish brown")
Report Abuse
astrosyedst is not online. astrosyedst
Joined: 19 Oct 2012
Total Posts: 458
30 Nov 2014 11:25 PM
:D work thank you darknightofVorhan
Report Abuse
astrosyedst is not online. astrosyedst
Joined: 19 Oct 2012
Total Posts: 458
30 Nov 2014 11:32 PM
but it only work once
Report Abuse
darknightofVorhan is not online. darknightofVorhan
Joined: 23 Jun 2008
Total Posts: 667
30 Nov 2014 11:38 PM
If you want it to happen more than once then use this:

local parent = script.Parent
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()

local function onClick()
char.Head.BrickColor = BrickColor.new("Reddish brown")
end

parent.MouseButton1Click:connect(onClick)
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
01 Dec 2014 12:23 AM
Better yet save space and make it an anonymous function, since you probably won't call it again.

local parent = script.Parent
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()

parent.MouseButton1Click:connect(function()
char.Head.BrickColor = BrickColor.new("Reddish brown")
end)

-The [Guy]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image