Hi, I have a problem with the clone tool. I am making a cafe game and whenever I press a button to make the drink, every cloned tool will be named that drink.
Script1:
local RS = game:GetService("ReplicatedStorage")
local events = RS:WaitForChild("events")
local event = events:WaitForChild("drinkEvent")
game.Players.PlayerAdded:Connect(function(plr)
script.Parent.Touched:Connect(function(part)
if part.Parent.Name == "Cup" then
event:FireClient(plr, part.Parent)
end
end)
end)
Local Script:
local RS = game:GetService("ReplicatedStorage")
local events = RS:WaitForChild("events")
local event = events:WaitForChild("drinkEvent")
event.OnClientEvent:Connect(function(cup)
script.Parent.Parent.Enabled = true
script.Parent.Frame.MilkDrink.MouseButton1Down:Connect(function()
script.Parent.Parent.Enabled = false
event:FireServer(cup, "Milk")
end)
script.Parent.Frame.WaterDrink.MouseButton1Down:Connect(function()
script.Parent.Parent.Enabled = false
event:FireServer(cup, "Water")
end)
end)
Script2:
local RS = game:GetService("ReplicatedStorage")
local events = RS:WaitForChild("events")
local event = events:WaitForChild("drinkEvent")
event.OnServerEvent:Connect(function(plr, cup, item)
if item == "Milk" then
cup.MilkDrink.Transparency = 0
cup.Sound:Play()
cup.Name = "Milk"
elseif item == "Water" then
cup.WaterDrink.Transparency = 0
cup.Sound:Play()
cup.Name = "Water"
end
end)
Here is a video of what happens.
robloxapp-20220306-0813276.wmv (1.8 MB)