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: clickdetectors

Previous Thread :: Next Thread 
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
27 Jun 2016 06:03 PM
part.ClickDetector.MouseClick:connect(function(player)

would be correct, right?




~The Low Brass Master
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 06:09 PM
I would assume so, as long as you made sure ClickDetector is a child of your specified part.

I must also point out though that you haven't closed your argument correctly, add an extra ) at the end of the line:

part.ClickDetector.MouseClick:connect(function(player))
Report Abuse
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
27 Jun 2016 06:19 PM
then why isn't it working

local cost = 20

script.Parent.ClickDetector.MouseClick:connect(function(player)
print'clicked'
if player.leaderstats.Points.Value >= cost and player.health.Value < 200 then
player.leaderstats.Points.Value = player.leaderstats.Points.Value - cost
player.health.Value = player.health.Value + 25
elseif player.health.Value >= 200 then
local clone = game.ReplicatedStorage.errorMessage:Clone()
clone.Parent = player.PlayerGui
clone.TextLabel.Text = 'You are at the maximum health!'
elseif player.leaderstats.Points.Value < cost then
local clone = game.ReplicatedStorage.errorMessage:Clone()
clone.Parent = player.PlayerGui
clone.TextLabel.Text = 'You need more points!'
end
end)

that's my total script, and it doesn't print clicked when I click it


~The Low Brass Master
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 06:35 PM
I said to add a ) at the end of the line.
Not the entire script.

Replace your line:

part.ClickDetector.MouseClick:connect(function(player)

With:

part.ClickDetector.MouseClick:connect(function(player))

And get rid of the ) at end of your script.
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 06:46 PM
^ You would be wrong there. That is incorrect syntax.

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 06:47 PM
Damn, really? How so?

Also, is this guy using a lot of his own variables? because i am pretty sure

player.health.Value

won't give him the health of his humanoid.
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 06:49 PM
When you are connecting an anonymous function, you are also creating it. Adding two parentheses right after the connection line wouldn't allow anything to be added into the body of it, and that would eliminate the requirement of an end.

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 06:50 PM
In fact, you haven't even enclosed your argument for print.

Shouldn't it be print('clicked') instead of print'clicked'?

What is going on here?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 06:53 PM
Calling print doesn't require parentheses

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 06:54 PM
Hmmm, do I feel stupid right now.

Seriously though, what is wrong with his script then?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 06:58 PM
probably because he doesn't have a value inside the player named "health" and he needs to change that to player.Character.Humanoid.Health

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 07:09 PM
I thought that was the correct path, but by the looks of it he may not be talking about the health you are given by default, perhaps it is his own value?

Anyway, back to the ClickDetector.

I just did this:

function clickScript ()
print"Clicked"
end

clickDetector1 = Instance.new("ClickDetector", game.Workspace.Part)

script.Parent.ClickDetector.MouseClick:connect(clickScript)

And it causes the output "Clicked" perfectly.

So try replacing your line with.

script.Parent.ClickDetector.MouseClick:connect(function)

and leave out the player portion maybe?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 07:11 PM
What does that have to do with "part.ClickDetector.MouseClick:connect(function(player))"

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 07:13 PM
It is literally the exact same line, but without the "(player)"?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 07:14 PM
no, it's not the exact same line; you're not closing the function like you did earlier

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 07:14 PM
...and it's not even an anonymous function

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
27 Jun 2016 07:22 PM
except then it would print clicked, because that's before the rest of the script, so it'd have to be the event that's not working


~The Low Brass Master
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 07:26 PM
what you're talking about is completely irrelevant to everything in this thread

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TrickyBoomBoom is not online. TrickyBoomBoom
Joined: 27 May 2009
Total Posts: 47
27 Jun 2016 07:45 PM
Well we are obviously in two completely different places so I am going to just disappear from this thread and act like it never happened, I suppose I would just do it differently, hopefully you can help this guy better than I.
Report Abuse
Exzeption is not online. Exzeption
Joined: 01 Nov 2011
Total Posts: 1312
27 Jun 2016 07:47 PM
it is relevant, the function isn't even being called was my point


~The Low Brass Master
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
27 Jun 2016 08:09 PM
local cost

ErrorMsg = function(player,msg)
local clone = game.ReplicatedStorage.ErrorMessage:Clone()
clone.Parent = player.PlayerGui
clone.TextLabel.Text = msg
end

script.Parent.ClickDetector.MouseClick:connect(function(player)
local stats = player:WaitForChild("leaderstats")
local points = stats.Points
local human = player.Character.Humanoid
if points.Value >= cost and human.Health < 200 then
points.Value = points.Value - cost
human.Health = human.Health + 25
elseif human.Health >= 200 then
ErrorMsg(player,"You are at the maximum health!")
elseif points.Value < cost then
ErrorMsg(player,"You need more points!")
end
end)


Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 08:17 PM
@time
stop giving me tumors with those free handouts lol

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
27 Jun 2016 08:18 PM
I got tired of you people being idiots and giving him wrong info.


Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
27 Jun 2016 08:18 PM
can you tell me where I went wrong in this thread?

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
27 Jun 2016 08:20 PM
You kept on ranting about the other posters errors when you should have been helping OP


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