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

Why doesn't this BrickColor/Transparency script work?

Asked by 5 years ago

I've been trying to figure this out for days. Some people have told me I need to use a remote event, which I've tried but possibly got the syntax incorrect, others have told me I don't need one and that I should be able to it all server side. I can't figure out the issue so I'm asking this forum. It's a coffee script that's supposed to rename the tool, change the transparency of the 'drink' brick inside the tool to 0 and the brick color to whatever the drink should be. It all works perfectly in studio but not outside of studio, and it works outside of studio if it's in experimental mode. I have no idea what the issue is or how I would even go about using a remote event for this if I need one, I just can't wrap my head around the usage even though I've looked at the wiki pages for hours. I'm desperate at this point, I feel like I've tried everything. This is an example script for the milk steamer:

function makeLatte(cup)
    print(cup.Name)
    if cup.Parent.Name == "Espresso" then
        print("Espresso")
        cup.Parent.Name = "Latte"
        cup.Parent.Drinkk.BrickColor = script.LatteColor.Value -- LatteColor, MilkColor, and MochaColor are BrickColorValues that are children of the script.
        cup.Parent.Drinkk.Transparency = 0
    elseif cup.Parent.Name == "EmptyCup" then -- EmptyCup is the default name of the tool.
        print("EmptyCup")
        cup.Parent.Name = "SteamedMilk"
        cup.Parent.Drinkk.BrickColor = script.MilkColor.Value
        cup.Parent.Drinkk.Transparency = 0
    elseif cup.Parent.Name == "Chocolate Syrup" then
        print("Chocolate Syrup")
        cup.Parent.Name = "Hot Chocolate"
        cup.Parent.Drinkk.BrickColor = script.LatteColor.Value
        cup.Parent.Drinkk.Transparency = 0
    elseif cup.Parent.Name == "Chocolate Espresso" then
        print("Chocolate Espresso")
        cup.Parent.Name = "Mocha"
        cup.Parent.Drinkk.BrickColor = script.MochaColor.Value 
        cup.Parent.Drinkk.Transparency = 0
    end
end
script.Parent.Touched:Connect(makeLatte)

Extra info: the script itself is not a local script, it's located within the block that must be touched for the script to run, which is an invisible non-colliding brick within the milk steamer. Please, any help is appreciated.

0
When did you define what cup is? lunatic5 409 — 5y
0
Cup is the argument - it's whatever is touching the brick the script is within. DropWater 10 — 5y
0
And yes, this should all be done server side (unless, that is, you only want the events to occur for a specific player). lunatic5 409 — 5y
0
Oops, my bad. My having only 2 brain cells and my IQ of 3 aren't much of a help. lunatic5 409 — 5y
0
Oh, thanks! And no problem at all, haha. DropWater 10 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Good question. For the BrickColor, try using BrickColor.new(VALUE). That may work.

Cup.Name returns "Handle" or whatever touches the part. Your cup is usually named "Handle" being that most cups are meshes.

Here is a hierarchy:

IMAGE

In this hierarchy, the object that will be touching the part is called "Handle." To return the name of the tool, you will need to use the following code (I use a different way for .Touched).

script.Parent.Touched:Connect(function(touch)
    if touch.Parent:IsA("Tool") then
        print(touch.Parent.Name) -- Returns with **Tool** as it's the name of the tool.
    end
end)

I can see your frustration and recommend you contact me on Discord. I can further assist you there and get more information on this issue.

Bark#4260

Ad

Answer this question