Hey there, I am trying to make a system where in this case, and empty cup will touch a part, which then removes the empty cup and replaces it with a full cup. Although, whenever I run the game, everything inside the “Cup” group is destroyed. Does anyone have any ideas why?
This is the only script in the group:
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Empty" then
print("Empty Detected")
script.Parent.Parent.Empty.Union:Destroy()
script.Parent.Parent.Full.Cup.Transparency = 0.7
script.Parent.Parent.Full.Liquid.Transparency = 0.4
script.Parent.Parent.Full.Cup.Position = true
script.Parent.Parent.Full.Liquid.CanCollide = true
print("Water added")
end
end)
This is how it appears in Studio:
And this is how it appears when I run the game:
If anyone knows what is happening, please tell me!
1 Like
Replace true with a vector3 value?
true
is not a valid Position of a BasePart’s Position what-
Position
properties take Vector3
values, and for some reason setting your Position
to true apparently deletes the cup
It literally depends on where you want to set your position of the cup, but this should be fixed:
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Empty" then
print("Empty Detected")
script.Parent.Parent.Empty.Union:Destroy()
script.Parent.Parent.Full.Cup.Transparency = 0.7
script.Parent.Parent.Full.Liquid.Transparency = 0.4
script.Parent.Parent.Full.Cup.Position = Vector3.new(0, 0, 0) --Set the X, Y, and Z values relative to the world origin
script.Parent.Parent.Full.Liquid.CanCollide = true
print("Water added")
end
end)
1 Like
I’m not quite sure what that means, I’m more of a builder than a scripter
@JackscarIitt explains it in a better way than I did lol.
Wow, I was messing around with positions and meant to set “Position” back to CanCollide, this is why the DevForum helps so much! I just needed an extra set of eyes
2 Likes
Think of the property screen when you click on a BasePart
, and its properties open up
You can kinda see that some of properties assigned, have 3 values: X, Y, and Z
Vector3
values coordinate with a 3d-dimension pretty much
Yeah that makes a lot of sense