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 » Scripting Helpers
Home Search
 

"OnClicked" script error, help please.

Previous Thread :: Next Thread 
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 09:40 AM
I've basically changed a script and tried to make it so "OnClicked" the function will work.

The thing I'm attempting to make it click is a surface GUI button. The surface gui is on a brick and the script is in the surface gui

-- Script by Hawk2Eye

timeuntilwin = 5
totaltime = 5

raidteamcolor = "Bright green"
defendteamcolor = "Bright red"
h = Instance.new("Hint")

function OnClicked(clicked)

if clicked.Parent:findFirstChild("Humanoid") ~= nil then
if game.Players:GetPlayerFromCharacter(clicked.Parent).TeamColor == BrickColor.new(raidteamcolor) then
script.Parent.BrickColor = BrickColor.new(raidteamcolor)
end

if game.Players:GetPlayerFromCharacter(clicked.Parent).TeamColor == BrickColor.new(defendteamcolor) then
script.Parent.BrickColor = BrickColor.new(defendteamcolor)
timeuntilwin = totaltime
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Hint") then
v:remove()
end
end
end

end

end

script.Parent.Clicked:connect(OnClicked)

while true do
wait()
if script.Parent.BrickColor == BrickColor.new(raidteamcolor) then
h.Parent = game.Workspace
h.Text = "The Raiders will win in".." "..timeuntilwin

if timeuntilwin <= totaltime and timeuntilwin > 0 then
wait(1)
timeuntilwin = timeuntilwin - 1
end

if timeuntilwin == 0 then
h:remove()

winmsg = Instance.new("Message")
winmsg.Parent = game.Workspace
winmsg.Text = "Raiders have won!"
wait(2)
winmsg:remove()

script.Parent.BrickColor = BrickColor.new(defendteamcolor)
timeuntilwin = totaltime
end
end
end
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
10 Sep 2014 09:42 AM
tldr
which line is it erroring on

guise i have a siggy
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 09:43 AM
It doesn't tell me D:

Nothing is underlined and the output window isnt saying anything
Report Abuse
vlekje518 is not online. vlekje518
Joined: 10 Apr 2011
Total Posts: 191
10 Sep 2014 09:44 AM
then where did you get the "OnClicked" error
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 09:48 AM
well it wont work so > error
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 09:52 AM
qq
Report Abuse
RetiredColonel is not online. RetiredColonel
Joined: 10 Feb 2014
Total Posts: 2230
10 Sep 2014 09:58 AM
script.Parent.Clicked:connect(OnClicked)

It is
script.Parent.Button.MouseButton1Down:connect(OnClicked)
(assuming script is in Surface GUI instance and not in the button
Report Abuse
DracoTrainingMaster is not online. DracoTrainingMaster
Top 100 Poster
Joined: 14 Oct 2006
Total Posts: 524
10 Sep 2014 09:59 AM
add some prints()
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 10:01 AM
the script IS in the surface gui e.e

will it still work if its not in the gui button
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 10:05 AM
I've put, the surface gui in a brick, a textbutton in the surface gui and the script in the textbutton and it doesnt work qq
Report Abuse
hawk2eye is not online. hawk2eye
Joined: 03 May 2010
Total Posts: 8525
10 Sep 2014 10:07 AM
hi
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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