Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can anybody help with an OnTouch Script?

So what I'm trying to do is make a script where if you touch a part then you get 1 win and 15 points. So here is the script. So what am I supposed to do?

function onTouch()
	script.Parent.Touched + 1 Wins
end
script.Parent.Touched:connect(onTouch)
function onTouch()
	script.Parent.Touched + 15 Points
end
script.Parent.Touched:connect(onTouch)

1 answer

I would downvote but it doesn't let me, no offense.

On line 2 and 6, its script.Parent.Touched. What does touched mean? the function doesn't carry the hit arguement and has no idea what Touched is.

Also on line 2 and 6, look at the fact it has + 1 win or whatever. If you are using default leaderstats it should be, hit.Parent.leaderstats.Wins.Value = hit.Parent.leaderstats.Wins.Value + 1

A log from f9 in server side would help aswell since it shows the debug and everything the game doesn't understand in the script.

2 functions are the same? Thats stupid. Make 1 function. Here is the final script. Also note I will take credit in the game as your last hope..

function onTouch(hit)
    local plr = hit.Parent
    plr.leaderstats.Wins = plr.leaderstants.Wins + 1
    plr.leaderstats.Points = plr.leaderstants.Points + 15
   
end

script.Parent.Touched:connect(onTouch)



2 comments

1

damn you need to calm down, not every person knows how certain pieces of code work.

0

Sorry, I've seen alot of Noobs, and they teach Ontouch as the first function on Roblox wiki. DOes nobody read it.

This discussion is preserved as it was. New answers, comments, and votes are closed.