You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to make a system that checks if a players hand has matching pairs of cards, and if so, remove them.
2. What is the issue? Include screenshots / videos if possible!
When there is 3 of a card value it removes all 3 of them instead of just 2.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
function GoFish.CheckForMatches(folder, number, fish)
for i, v in pairs(folder:GetChildren()) do
local value = string.sub(v.Name, 1, 2)
for i, card in pairs(folder:GetChildren()) do
local value2 = string.sub(card.Name, 1, 2)
if value == value2 and v.Name ~= card.Name then
GoFish.Matches(card, v, number, fish)
break
end
task.wait()
end
end
end
function GoFish.Matches(card1, card2, player, fish)
card1.Parent = fish.Matches
card2.Parent = fish.Matches
local gui = fish:FindFirstChild("Matches"..player)
gui.Matches.Amount.Value += 1
gui.Matches.AmountText.Text = gui.Matches.Amount.Value.." Matches"
task.spawn(function()
local info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local tween = TweenService:Create(card1, info, {["CFrame"] = card1.CFrame + Vector3.new(0,3,0), Transparency = 1})
tween:Play()
tween.Completed:Connect(function()
card1:Destroy()
end)
end)
task.spawn(function()
local info2 = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
local tween2 = TweenService:Create(card2, info2, {["CFrame"] = card2.CFrame + Vector3.new(0,3,0)})
tween2:Play()
tween2.Completed:Wait()
card2:Destroy()
end)
end
This is what I’ve tried so far. (The fish var is just the whole folder of the Go Fish game).
(The folder var is the players hand).
I’m sorry if I did something wrong this is my first post. Please politely tell me how to improve my post for next time!