Hey, Developers.
I’ve been looking forward to get assistant which ever related to the Topic currently, I’m needing an assistant. My idea is to make a certain position gives a Uniform, any idea or instructions? Scripts aren’t needed to be posted.
Hey, Developers.
I’ve been looking forward to get assistant which ever related to the Topic currently, I’m needing an assistant. My idea is to make a certain position gives a Uniform, any idea or instructions? Scripts aren’t needed to be posted.
What do you mean by position? A certain Vector3 point or CFrame or everywhere inside a Region3?
He’s probably referring to something like HumanoidRootPart.Position
Magnitude?
Region3?
When the person is on the Part’s position, it gives them a Uniform. I don’t exactly know.
part.Touched:Connect(function(hit)
if (hit.Parent:FindFirstChildOfClass("Humanoid")) then -- is a player
-- do uniform stuff
end
end)
Ah, thank you. It really helps a lot even it’s simple as I’m just a beginner. Thank you once again.
Ah, well what you can do is implement what’s called a Touched
Event for BaseParts
local Part = script.Parent
Part.Touched:Connect(function(Hit)
end)
This Event will pretty much fire as soon as it comes in contact with another Part via physics, and it also returns the HitPart
as the parameter
First though we’d need to check if the Player that we want to give the Uniform to is a valid Player, & we’d probably want to do this once so we could do this by using some conditional checks using the GetPlayerFromCharacter()
function provided by the Players Service, and checking if the Player does not the uniform:
local Part = script.Parent
Part.Touched:Connect(function(Hit)
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
local Character = Hit.Parent
if Character:FindFirstChild("Uniform") == nil then
--This is where you can handle the Uniform Cloning to the parent
end
end
end)
Since Hit
returns back the HitPart
, we can use Hit.Parent
to get the Character’s Model like so & checking if we have a valid Player or not
Next we can check if the Character does have the Uniform
inside its Model, if it’s equal to nil
(Or doesn’t exist) then we can set up our script to give our uniform
This is just a sample code, but feel free to do mess around at your will with it