Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can't my touched script edit the tool a player is holding?

Asked by
Jexpler 63
7 years ago
Edited 7 years ago

Here is my script:

script.Parent.Touched:connect(function(hit)
        if hit.Parent.Name == "Cup_Empty" then
        hit.Parent.Handle.Liquid.Transparency = 0
    end
end)

Basically, I am trying to get it to when the tool Cup_Empty hits this object, in my case milk, it will make the liquid inside of it go from invisible to visible. Is something wrong with my script? Or is there some weird thing with tools that I don't know.

0
Is the script inside the tool? It's likely that script.Parent is the tool object, not the Handle. Since the Handle is the actual part, you have to connect the touched event to it. Perci1 4988 — 7y
0
Also, the script is iside of the milk container. Jexpler 63 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Are you 100% sure that it's the tool that touches it and not the player? What I suggest you do is that instead of doing it when only the tool touches it, makes it when a player touches it, it checks if one of the tools the player has inside his/her backpack is called "Cup_Empty" and if it's "empty" or whatever you want to do you do your stuff

0
What I did beforehand was told it to print hit.Name It hit the hand and the handle. Jexpler 63 — 7y
Ad

Answer this question