I’m basically making a coffee machine, when you touch it with a tool of a specific name, it renames it and the machine functions.
Unfortunately, what I am experiencing is the fact that when the tool is in starter gear when I touch the machine with it it works, but if I touch the machine with a cup that I got from the cup giver it doesn’t work. It’s really strange and I’m not getting any errors.
I have tried moving the tool to server storage instead of replicated storage, but then I get an error saying the specific tool is nill. (Also let me note, I didn’t forget to make changes in the script for that)
Cup Giver Script (located in replicated first, local script):
local Player = game:GetService("Players")
local Mouse = Player.LocalPlayer:GetMouse()
local GroupID = 6164563
local MinimumRank = 3
function PickUp(Item)
if Mouse.Target == script.Target.Value and Player.LocalPlayer:GetRankInGroup(GroupID) >= MinimumRank and script.Cooldown.Value == false then
script.Cooldown.Value = true
local Backpack = Player.LocalPlayer.Backpack
local Item = script.Tool.Value
Item:Clone().Parent = Backpack
if script.Target.Value:FindFirstChild("SoundEffect") then
script.Target.Value.SoundEffect:Play()
end
wait(1)
script.Cooldown.Value = false
end
end
Mouse.Button1Up:Connect(PickUp)
Coffee Machine Script:
function tch(h)
if (h.Parent.Name == "Takeaway Cup") and h.Parent:IsA("Tool") then
script.Parent.Activate:Play()
script.Parent.Liquid.Transparency = 0
h.Parent.Name = script.Parent.Parent.Name
wait(0.5)
script.Parent.Liquid.Transparency = 1
end
end
script.Parent.Touched:Connect(tch)
Really would appreciate some help!