Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ontouch event problem ,can it be possible for little feed back and help?

Asked by 6 years ago

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

0
Future reference: Highlight the code you're providing, then click the LUA icon symbol. This formats the code to easily understand it. xPolarium 1388 — 6y
0
^ It's Lua. CootKitty 311 — 6y
0
What LUA do you mean here? http://acronyms.thefreedictionary.com/lua hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
6 years ago
Edited 6 years ago

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.

Errors are highlighted in red. This should be purple in the output:

20:06:18.752 - MY FPS game was auto-saved

This error isn't an error. Roblox studio is auto-saving your place. Normal occurance.

20:06:20.578 - Workspace.Part.Script:7: 'then' expected near 'hunger' 20:06:20.580 - name is not a valid member of IntValue

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.

0
do you think if i provide you my work place will you be able to further help me out because like you said im still garbage at this just started to look into GUIS and events Shark212 0 — 6y
0
Purple? What's purple is your game saving. Is your game saving the error? hiimgoodpack 2009 — 6y
Ad

Answer this question