|
| 03 Apr 2016 02:11 PM |
Hi everyone! I've been working on a cafe, and I can't seem to figure out how to make a certain function. I'm trying to make a script where when someone clicks on a coffee cup, it gives it to them.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Apr 2016 02:12 PM |
script.Parent.ClickDetector.MouseClick:connect(function(player) game.ServerStorage.CoffeeCup:Clone().Parent = player.Backpack end)
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2016 02:16 PM |
| It's not working. Am I supposed to put it under the coffee cup or rename something? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Apr 2016 02:17 PM |
server script into the part that the person clicks and put the coffecup into serverstorage
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2016 02:22 PM |
| I tried that... it's not working |
|
|
| Report Abuse |
|
|
Craftero
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1451 |
|
|
| 03 Apr 2016 02:23 PM |
Don't forget to add a ClickDetector!
You can do this as follows:
1.) Click on the "MODEL" tab in Roblox Studio
2.) Click "Advanced Objects"
3.) From here a window will pop up. Click on the Part that you want to be the button.
4.) In the window that popped up, click ClickDetector. This will add the ClickDetector to the Part. This makes it "clickable"!
I'm not sure how familiar you are with Studio as I haven't seen you in this Forum before, so I just included the steps for you. Hope this helps ;) |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2016 02:24 PM |
| Thanks! You guys are so helpful! And I'm very familiar with Studio (I'm still in the process of learning Lua), but I'm just new to the forum. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2016 02:32 PM |
| Er... it still doesn't work. Maybe something wrong with the code? |
|
|
| Report Abuse |
|
|
OmariHero
|
  |
| Joined: 14 Aug 2013 |
| Total Posts: 4193 |
|
|
| 03 Apr 2016 02:51 PM |
this is an old script of mine back when i attempted to make a cafe
function hi(x) y = x.Backpack z = game.Lighting["Pizza"] z:Clone().Parent = y end
script.Parent.ClickDetector.MouseClick:connect(hi)
it works perfect just used ReplicatedStorage instead of Lighting |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Apr 2016 02:52 PM |
There is literally nothing wrong with the script. You are just doing something wrong. Send a picture of the thing
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2016 02:53 PM |
*Bump*
This is pretty urgent ;-; |
|
|
| Report Abuse |
|
|
OmariHero
|
  |
| Joined: 14 Aug 2013 |
| Total Posts: 4193 |
|
| |
|
|
| 03 Apr 2016 02:53 PM |
| nothing in this forum is urgent lol |
|
|
| Report Abuse |
|
|
| |
|
Craftero
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1451 |
|
|
| 04 Apr 2016 07:30 AM |
I think I know what's wrong.
The CoffeeCup Model is not in ServerStorage. Drag the CoffeeCup Model into ServerStorage in the Explorer tab.
I know you're kind of new to scripting, so here's an explanation as to why this is necessary. I'll number the lines of the code, 1, 2, 3 respectively. Don't do this in the code!!
1.) script.Parent.ClickDetector.MouseClick:connect(function(player) 2.) game.ServerStorage.CoffeeCup:Clone().Parent = player.Backpack 3.) end)
1. Line one finds it's parent and then finds the ClickDetector that is a child of that object. MouseClick is an Event which means "when it's clicked, do the following".
2. Line two goes to ServerStorage and searches through everything in there until it find the model named CoffeeCup. It clones it and sets the clone's parent to the Player's backpack. This gives them the cup of coffee.
3. Line three? We'll line three's just an "end"!
I don't see any reason why this shouldn't work now, but if it doesn't just let me know and I'll try to help you out. |
|
|
| Report Abuse |
|
|