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: GUI that gives hat when clicked

Previous Thread :: Next Thread 
SapphireBuilding is not online. SapphireBuilding
Joined: 02 Jan 2015
Total Posts: 203
13 Jan 2015 02:55 PM
Ok I have been trying for ages and I can't get this to work someone help me pls.

function onButtonClicked()

player = script.Parent.Parent.Parent.Parent.Parent.Character

h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "ArmyHelmet"
p.Parent = h
p.Position = player.Head.Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(0, 0, 0)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
game.ServerStorage.Mesh:Clone().Parent = p
h.Parent = player
h.AttachmentPos = Vector3.new(0, 0, 0)


end

script.Parent.MouseButton1Click:connect(onButtonClicked)
Report Abuse
EliteDerper is not online. EliteDerper
Joined: 05 Feb 2012
Total Posts: 2288
13 Jan 2015 02:58 PM
ServerStorage is for scripts only.
And since your working with localscripts, it won't work.

Try working with Lighting or ReplicatedStorage.
Report Abuse
025110 is not online. 025110
Joined: 23 Nov 2012
Total Posts: 57661
13 Jan 2015 02:59 PM

why are you cloning the mesh and not the hat lol?

R$6,526
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
13 Jan 2015 02:59 PM
LocalScript?

If yes, then LocalScripts can't acess ServerStorage, use ReplicatedStorage instead.
Report Abuse
SapphireBuilding is not online. SapphireBuilding
Joined: 02 Jan 2015
Total Posts: 203
13 Jan 2015 03:02 PM
None of the scripts are local scripts, also the script im using only requires the mesh to be cloned.
Report Abuse
SapphireBuilding is not online. SapphireBuilding
Joined: 02 Jan 2015
Total Posts: 203
13 Jan 2015 03:05 PM
bump
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
13 Jan 2015 03:06 PM
GUI's need LocalScripts.
Report Abuse
MrNoobe123 is not online. MrNoobe123
Joined: 14 Nov 2014
Total Posts: 153
13 Jan 2015 03:06 PM
bump, I want to know this too D:

~Do not be confident unless you know whats under the hood.~
Report Abuse
MrNoobe123 is not online. MrNoobe123
Joined: 14 Nov 2014
Total Posts: 153
13 Jan 2015 03:07 PM
@Power, no they don't...

~Do not be confident unless you know whats under the hood.~
Report Abuse
EliteDerper is not online. EliteDerper
Joined: 05 Feb 2012
Total Posts: 2288
13 Jan 2015 03:08 PM
@MrNoobe
Actually most of them have to.
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
13 Jan 2015 03:09 PM
Yes they do.
You need to transfer it to a LocalScrip, and move the mesh to ReplicatedStorage; since LocalScripts can't acess ServerStorage.
Report Abuse
MrNoobe123 is not online. MrNoobe123
Joined: 14 Nov 2014
Total Posts: 153
13 Jan 2015 03:10 PM
You said "GUI's need LocalScripts." meaning ALL GUIs...

~Do not be confident unless you know whats under the hood.~
Report Abuse
MisBloxy is not online. MisBloxy
Joined: 13 Sep 2008
Total Posts: 164
13 Jan 2015 03:10 PM
first of all, server storage is for any type of object. its serverScriptServe that is only for scripts. put the hat in server storage, clone that hat using a localScript, and parent it to the player's character.
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:14 PM
You shouldn't need a local script if your using a gui just saying it's already what I would call 'semi-client sided'

Step 1:
Put your hat in replicated storage

Step 2:
Insert a script and put it inside the button

Step 3:
Edit the script with the following code:

hat = game.ReplicatedStorage.hat -- edit 'hat' with the hat's name that's in repstorage
player = script.Parent.Parent.Parent.Parent -- Ussing the button is found at starterGui > -- GUINAME > button

script.Parent.MouseButton1Click:connect(function()
hat:Clone().Parent = game.Workspace:FindFirstChild(player.Name)
end)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
13 Jan 2015 03:15 PM
guys.... Gui's fo not need local scripts, they can work with server scripts you just have write it a bit different
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:15 PM
p.Size = Vector3.new(0, 0, 0) -- If I'm correct a brick can't be 0,0,0 or it's considered 'nil'
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:16 PM
@chimmihc, Mine is supposed to be a script, a normal one.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
13 Jan 2015 03:19 PM
sorry dude I would debug your script but I'm on my phone
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:20 PM
My script shouldn't need 'debugging'.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
13 Jan 2015 03:21 PM
if it doesn't work then it does
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:22 PM
Should work, don't see why it couldn't.
Report Abuse
SapphireBuilding is not online. SapphireBuilding
Joined: 02 Jan 2015
Total Posts: 203
13 Jan 2015 03:22 PM
@Faded didn't work, I edited it so it would be precise but It still didnt work, I do have a hat remover script that works at the same time as this but it should still work right? Also I added print("Done") at the end and that didnt show in output so the script didn't work.
Report Abuse
MrNoobe123 is not online. MrNoobe123
Joined: 14 Nov 2014
Total Posts: 153
13 Jan 2015 03:24 PM
Faded... It doesnt work...

~Do not be confident unless you know whats under the hood.~
Report Abuse
SapphireBuilding is not online. SapphireBuilding
Joined: 02 Jan 2015
Total Posts: 203
13 Jan 2015 03:24 PM
Ok I took out the remvoer script and played the script faded suggested it worked but now I need the hat remover script to activate before the Hatgiver script how do i do that?
Report Abuse
FadedExistence is not online. FadedExistence
Joined: 28 Jun 2011
Total Posts: 818
13 Jan 2015 03:26 PM
wait() could be your best friend
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