#how can i count the amount of times the touched event has been fired
1 messages · Page 1 of 1 (latest)
local counter = 0;
part.Touched:Connect(function(hit)
counter += 1;
end)
um
so i have questions to do with how that works
because i also want to understand it
for lua local counter = 0; what does the semi colon do
and also what does hit do
nothing
it does nothing
just a habit when you use other languages other than roblox lua
oh
and what about hit
ive seen it used in other scripts but idk what it does
oh yh and what does that += symbol mean togethor
hit is the part which the main part has touched
it means, it will add to the total
basically a simplified version of x = x + 1
a little confused by that
oh ok
When PartA, the one with the Touched Event, which in this example is part comes in contact with PartB.
is hit an event?
No.
eh
so hit just means when to parts touch eachother?
hit is PartB. So yes.
idk if i understand it properly
cos in that way it sounds a lot like an event
where can i read abuot it
Touched is the event.
hit is PartB. hit is the part PartA has made contact with.
oh ok
so when a players character walks into a part
and they have touched it
which one of them is hit
Any part.
Any parts in the class of BasePart.
It can be a union, wedge, part, meshpart.
so it can never be a player?
It can't be anything other than a part.
So yes.
It would not return the instance of player.
a players character i mean
No.
like their arm
A player's character is a model and not a basepart.
oh ok
That's a basepart.
eh.
damn
uh
ig what im tryingg to ask is
if im playing the game
and i talk into a block
which is a base part
am i able to be "hit"
The BasePart would be any part that has touched PartA.
wht do u mean by part A
PartA is referred as the part with the touched event.
e.g. workspace.RandomPart.Touched
That would be PartA
oh ok
ohhhhh ok i think i get it now
so if i say ```lua
local part = workspace.part
part.touched:connect(function
-- code
end)```
the part is touch A ?
i mean.
the part is partA?
and what ever just touched it is partB
Yes, Correct.
alrrrr so my players character is hit then ?
not their character
but what ever part of their avatar just hit the part
@exotic cloak focus on actually programming and not getting the newest syntax correct
syntax can be learned but not universally applied.
fundamental programming can be universally applied.
its a part of what im making
long term ^^
basically i want to make a win system
where the first 3 players to cross the finish line are put in order
on this like
eh idk wht to call it
platform
where the 1st winner is the hiest
highest*
so the idea i had was to count the amount of times its been touched
and then make a function that inerts a players character model
and it obiously depends on what ever count is equal to