I attempted this by using a script but doesn’t work and no errors.
local Part = script.Parent
local A1Card = game.ReplicatedStorage.A1Card
local debounce = false
function onTouched(p)
local humanoid = (p:FindFirstAncestorOfClass("Model") or p.Parent):FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
local leaderstats = player:FindFirstChild("leaderstats")
local Coins = leaderstats:FindFirstChild("Gold")
if p.Parent == player then
if Coins then
if Coins.Value > 299 then
Coins.Value = Coins.Value - 300
A1Card:Clone(player.Starterpack)
end
end
end
end
script.Parent.Touched:connect(onTouched)
In the code you gave, player is the Player instance, not the player’s character. You can see this from player = game.Players:GetPlayerFromCharacter(humanoid.Parent), because :GetPlayerFromCharacter returns the Player instance associated with the player character. If you wanted the character, you would just use humanoid.Parent.
Also I strongly suggest adding a check that humanoid is not nil under the local humanoid = ..., because otherwise the game will break if anything other than part of the player’s character touches the part.