#what does "Otherpart" do?
1 messages · Page 1 of 1 (latest)
i got you
print(otherPart)
so if we print otherPart
otherPart is ANYTHING that touches the part
meaning parts like SpawnLocation
and your body parts on your character
if we peek inside of a player thats loaded into the game
you can see all their body parts and something called "Humanoid"
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
thats where this comes in
so visualise it like this
LeftLowerLeg.Parent which is our model with your player name
thats why it prints my name
print(otherPart.Parent)
** You are now Level 16! **
your character FINDTHEFIRSTTHINGCALLED ("Humanoid")
oh wait so otherpart gets the first child of "Humanoid"?
i mean that little code segment
otherpart is say your leg that touched the part
otherpart.Parent is your character
as your character is the parent of the leg
Gabeisvibing is my username ofc
everything inside is a child to it as its inside it
so all that code means is look inside Gabeisvibing for something called "Humanoid"
oh ok
wait
another quick question
im making a quick little obby game to test my skills ya know
and i have this yellow ball thats a coin
when i touch the coin it doesn't make my leaderstat go up
you named it coins not coin
i have made that mistake plenty of times too loll
https://www.youtube.com/watch?v=evBhoqeYegQ
if you want to make a player data saving system without needing to know to much just yet
i always recommend this as it helped me a ton
Today we look at a new library for easily saving player data inside of Roblox! The Profile Store library is created by the same developer of the Profile Service library, which we've used for saving our player data for so long.
Subscribe for more Roblox development tutorials!
Profile Store Dev Forum post:
https://devforum.roblox.com/t/profilesto...
leaderstats is cool but not safe as youd have to save it on the client
changing it to coins doesn't fix it either
wait out of curiosity
when doing the leaderstats thing you have a setINT for integer
i dont actually need a decimal but what if you wanted a decimal?
no IntValue cant do floats
NumberValue
local num = Instance.new("NumberValue")
num.Value = 3.5
oh ok
ok wait
should i make a seperate script for adding 1 to the player stats every time the player touches a coin? and if so where would that script go?
i think you need to do
coins.Value += 1
which just means
coins.Value = coins.Value + 1
set whatever it is + 1
coinPart.Touched:Connect(function(otherpart)
local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(otherpart.Parent)
if player then
local coins = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins")
if coins then
coinPart.Transparency = 0.7
coins.Value += 1
end
end
end
end)
another issue your having is it wont know what "coins" is
in your playeradded function you define what coins is so it knows
artist fr
the red part is outside of any function so its a global scope
meaning if you tried to reference something in global inside a functon no problem
anything in the green is in a function which is a local scope meaning only that function can see it
local coins = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins")
if coins then
coinPart.Transparency = 0.7
coins.Value += 1
so we tell it in your Touched function what coins is
its the folder inside of a specific player
then you can update their coins
so to answer no you dont but usually its good practice too
in a fully fledged game you might have a modulescript or normal script that has a function for that
then another modulescript or script specifically about creating and updating playerstats or playerdata
this is how you truly dip your toes into proper data storing if you want to make an actual game
if your just messing around to learn your doing perfect
ok ty for the help man your a lifesaver
also another quick (probably) question
is there an easy way to remove a part from the game once something has happened
guessing you found out about part:Destroy() lol