So i created a little part it is called orange just an orange sphere i have a Hunger GUI and i want it that when player touches it you will get say +20 hunger out of the 150 i got here is the hunger GUI script (WORKS) hunger = 150 local plr = game.Players.LocalPlayer while true do script.Parent.Text = ('%') .. hunger.. ('') wait(1) hunger = hunger - 1 if hunger == 0 then plr.Character.Humanoid.Health = 0 end end
then for the orange on touch event i found a model that actually worked and i was able to ontouch event make the models little part disapear using the code from the script that was provided , when i copy and paste it to mine double checked it for links it still wouldnt work
Code from the model i found : function Eat(hit) -- put this script in the cake
if (hit.Parent:findFirstChild("Humanoid") ~= nil) then script.Parent:Remove() end end end
script.Parent.Touched:connect(Eat)
and here is the output window error:
20:06:18.752 - MY FPS game was auto-saved 20:06:20.578 - Workspace.Part.Script:7: 'then' expected near 'hunger' 20:06:20.580 - name is not a valid member of IntValue
sorry if its confusing but to sum it up i have a part which when i walk over i want it to disapear and give my character +20 hunger which the hunger gui is already provided i have attempted multiple times and went on youtube and wiki for answers but my efforts were very hopeless :( thank you so much if you look into this :D I believe this is something to do with events
I believe your entire situation is just suffering from a severe case of bad code formatting. I'm also assuming that all this code is actually coming from free models or other's people scripts so it's kinda hard to know if you're providing everything.
This is how the code should look like in a LocalScript:
local hunger = 150 local plr = game.Players.LocalPlayer while true do script.Parent.Text = ('%') .. hunger.. ('') wait(1) hunger = hunger - 1 if hunger == 0 then plr.Character.Humanoid.Health = 0 end end
You also provide the errors which make me assume you don't really code at all. Which is fine, I'm still helping you.
This error isn't an error. Roblox studio is auto-saving your place. Normal occurance.
This is what confuses me and where I think you're not providing the full script.
IntValue is no where in the script so I guess this is another script somewhere in your place.
The 'then' expected near 'hunger'
is what tells me your code isn't properly formatted in your script. Make sure it looks like what I provided above and is also in a local script.