Changing players model when they touch a part

So I’m trying to make a powerup system like from the old Mario Platforming games. When the player touches a Fire Flower their model will turn into the Fire Mario model. how would I achieve this? I have a value folder in each player that keeps track of what character each player is so it’ll change their model depending on their character as well.

2 Likes

There are a few options for touch detection, I recommend checking out the roblox documentation as they have a few code examples on how to approach this.

Touched Event
This allows for code to run the moment you touch the part

fireFlowerPart.Touched:Connect(function(part)
    --check if the part is from the character
    --make sure this doesn't get run again!
end)

The options below will probably require you to check every frame or every so often
GetTouchingParts
This checks what parts are currently touching the part you provide.

GetPartsInPart
This checks what parts are currently inside the part you provide.

local touchedParts = fireFlowerPart:GetTouchingParts() --or 'GetPartsInPart'
--then check if the touchedParts are the character
2 Likes

I understand that part, but do you know how I would make it change the players model? I’ve tested a few things but I just can’t get the model to actually be put on the player.

1 Like

If you just want a model to stick on the player

You can try using WeldConstraint

local weld = Instance.new("WeldConstraint")
weld.Parent = partA
--make sure to adjust where the parts are first before this
weld.Part0 = partA
weld.Part1 = partB

But if you want to modify the player’s current model
TweenService can help make it look nice

1 Like