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: What's wrong with this script?

Previous Thread :: Next Thread 
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:24 AM
I'm trying to make a berry and when you touch it, it makes you less hungry but it doesn't work

function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
game.StarterGui.Hungerbar.Hunger = game.StarterGui.Hungerbar.Hunger +5
game.StarterGui.Hungerbar.Bar.Size = game.StarterGui.Hungerbar.Bar.Size +
UDim2.new(0,1,0)
script.Parent:Remove()
end
end
script.Parent.Touched:connect(onTouched)


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:26 AM
bump


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
CrimsonForce is not online. CrimsonForce
Joined: 11 Sep 2010
Total Posts: 35714
03 May 2015 10:27 AM
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Parent:GetPlayerFromCharacter(player)
player.PlayerGui.Hungerbar.Hunger = player.PlayerGui.Hungerbar.Hunger + 5
player.PlayerGui.Hungerbar.Bar.Size = player.PlayerGui.Hungerbar.Bar.Size + 1
UDim2.new(0,1,0)
script.Parent:Remove()
end
end
script.Parent.Touched:connect(onTouched)

not sure if that would work but yeah
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:29 AM
Didn't work but cheers.


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
logarhythm is not online. logarhythm
Joined: 23 Dec 2008
Total Posts: 10267
03 May 2015 10:29 AM
CrimsonForce has the right idea; you're trying to modify the GUI in StarterGui! You should change it only for one player.
Report Abuse
CrimsonForce is not online. CrimsonForce
Joined: 11 Sep 2010
Total Posts: 35714
03 May 2015 10:30 AM
okay
so what you need to do is get the player from the humanoid's character
and from there, manipulate the gui.
you cant manipulate a whole StarterGui, as it wouldn't change on the screen, but it would change for the whole server
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:31 AM
But how do I do it? I'm pretty new at scripting still


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:35 AM
bump


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
logarhythm is not online. logarhythm
Joined: 23 Dec 2008
Total Posts: 10267
03 May 2015 10:37 AM
You're finding the Character (part.Parent). You need to find the Player.
The easy way of doing that:

local partPlayer = game.Players:FindFirstChild(part.Parent.Name)
if partPlayer then
-- do something; the GUI should be in partPlayer.PlayerGui
end

You should load a character into the game and find it in their Player.
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:43 AM
So do I do this?

local partPlayer = game.Players:FindFirstChild(part.Parent.Name)
if partPlayer then
game.StarterGui.Hungerbar.Bar.Size = game.StarterGui.Hungerbar.Bar.Size + UDim2.new(0,1,0)
script.Parent:Remove()
end


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:47 AM
bump


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:52 AM
bump


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
fincreator8 is not online. fincreator8
Joined: 14 Jul 2013
Total Posts: 8156
03 May 2015 10:59 AM
bump


Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]-
Report Abuse
logarhythm is not online. logarhythm
Joined: 23 Dec 2008
Total Posts: 10267
03 May 2015 11:21 AM
no, you're still modifying the GUI in StarterGui.

local partPlayer = game.Players:FindFirstChild(part.Parent.Name)
if partPlayer then
game.StarterGui.Hungerbar.Bar.Size = game.StarterGui.Hungerbar.Bar.Size + UDim2.new(0,1,0) -- still changing "game.StarterGui ..."
script.Parent:Remove()
end

local partPlayer = game.Players:FindFirstChild(part.Parent.Name)
if partPlayer then
partPlayer.PlayerGui.Hungerbar.Bar.Size = game.StarterGui.Hungerbar.Bar.Size + UDim2.new(0,1,0)
script.Parent:Remove()
end
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