Hello,
I’ve been trying to make a coin that gives you gold according to your pet’s multiplier
but I noticed that the script doesn’t work well
Is there something I missed?
local coin = script.Parent
local Players = game:GetService("Players")
local function onTouch(otherPart, Multiplier1)
local character = otherPart.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
local leaderstats = player:FindFirstChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
local Multi = 0
for i,v in pairs(player.Pets:GetChildren()) do
if v.Equipped.Value == true then
Multi = Multi + v["Multiplier1"].Value
print(Multi)
if humanoid then
local amount = 100 * Multi
coins.Value = coins.Value + amount
coin.CanTouch = false
wait(5)
coin.CanTouch = true
end
end
end
return Multi
end
coin.Touched:Connect(onTouch)
local coin = script.Parent
local Players = game:GetService("Players")
local function onTouch(otherPart, Multiplier1)
local character = otherPart.Parent
local humanoid = character:FindFirstChild("Humanoid")
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
local leaderstats = player:FindFirstChild("leaderstats")
local coins = leaderstats:WaitForChild("Coins")
local Multi = 0
for i,v in pairs(player.Pets:GetChildren()) do
if v.Equipped.Value == true then
Multi = Multi + v["Multiplier1"].Value
print(Multi)
end
end
if humanoid then
local amount = 100 * Multi
coins.Value = coins.Value + amount
coin.CanTouch = false
wait(5)
coin.CanTouch = true
end
return Multi
end
coin.Touched:Connect(onTouch)