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: Item giving script

Previous Thread :: Next Thread 
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
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 is not online. 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
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
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 is not online. 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
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
03 Apr 2016 02:22 PM
I tried that... it's not working
Report Abuse
Craftero is not online. 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
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
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
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
03 Apr 2016 02:32 PM
Er... it still doesn't work. Maybe something wrong with the code?
Report Abuse
OmariHero is not online. 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 is not online. 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
ClassicCollie is not online. ClassicCollie
Joined: 14 Feb 2016
Total Posts: 41
03 Apr 2016 02:53 PM
*Bump*

This is pretty urgent ;-;
Report Abuse
OmariHero is not online. OmariHero
Joined: 14 Aug 2013
Total Posts: 4193
03 Apr 2016 02:53 PM
ya
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
03 Apr 2016 02:53 PM
nothing in this forum is urgent lol
Report Abuse
DesertedVoltron is not online. DesertedVoltron
Joined: 12 Jul 2011
Total Posts: 33
03 Apr 2016 03:13 PM
#code print(ddddddd)
Report Abuse
Craftero is not online. 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
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