Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

[SOLVED] How to make part that alters the appearance of tools?

Asked by 6 months ago
Edited 6 months ago

How would I make it when a player touches a part with a tool in their hand the tool will be altered.

I am trying to make it so when you hold an empty coffee pot in your hand and go to a coffee machine, the coffee which has its transparency set to 1 becomes 0 so you can see it, as well as the name being changed.

Any suggestion would be helpful.

1 answer

Log in to vote
0
Answered by 6 months ago
Edited 6 months ago

Any tool that you're holding is inside of your character. You can use Part.Touched to detect if a player goes to the machine. A nice example would be this

local function fillcup(cup)
    if cup.Filled.Value == false then --checks if the cup is filled
        cup.Filled.Value = true
        --code to fill cup
        --maybe a nice fill animation aswell
    end
end
part.Touched:Connect(function(parttouching)
    if game:GetService("Players"):GetPlayerFromCharacter(parttouching.Parent) then --checks if what touched it is a player
        if parttouching.Parent:FindFirstChild("Cup") then --checks if the player is holding a cup
            fillcup(parttouching.Parent.Cup) --calls the function to fill the cup
        end
    end
end)

Where part is the bit of the coffee machine that you need to touch. Also there is a bool value in the cup called "Filled". And the cup should be named "Cup".

0
Thank you so much, this worked perfectly jacksworld2808 15 — 6mo
0
please accept my answer ThisIsAnAccount255 143 — 6mo
0
there should be a green checkmark ThisIsAnAccount255 143 — 6mo
0
I don't see a check mark? sorry this is my first time using this platform, where is it? jacksworld2808 15 — 6mo
0
I found it jacksworld2808 15 — 6mo
Ad

Answer this question