|
| 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 |
|
|
|
| 03 May 2015 10:26 AM |
bump
Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]- |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 03 May 2015 10:35 AM |
bump
Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]- |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 03 May 2015 10:47 AM |
bump
Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]- |
|
|
| Report Abuse |
|
|
|
| 03 May 2015 10:52 AM |
bump
Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]- |
|
|
| Report Abuse |
|
|
|
| 03 May 2015 10:59 AM |
bump
Lets get this published! -[http://www.roblox.com/Hungry-Piranha-item?id=185365082]- |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|