Hey there! I’m relatively new to scripting in Roblox studio so you’ll most likely see me a bit on here. I always seem to run into some sort of issue, but always find a solution on here. So far, I have not found one regarding my current issue so I felt like I should finally jump into some posts. My wife, my 7 and 6 year old and myself have started a roblox game creation journey and can use all the tips we can get.
My issue has to do with collision and sounds playing. I know it sounds super simple, and might very well be. However, I can’t seem to wrap my head around it. Perhaps I’m doing it all wrong. But I’ll try to give as much information as possible as well as what I’ve tried.
What I’m trying to achieve is that when a player collides with a model(ball), it plays a sound and disappears. It’s for one of those tycoon-esque games that people seem to like playing but the dev community hates. My kids are in love with them so I thought it would be a fun thing to make as a family. As well as teach them coding in the process. (Sorry in advance.)
It actually worked at first, but when the player collided with the ball, the ball still kept the shape after it disappeared and would cause the player to stop on collision(The sound on collision worked here). So I read into collision groups and after seeing some of the issues answered on here I was able to part together a solution for that issue. The collision group method seemed to work better than the script itself. However I’m at a point where I think they might be conflicting with each other.
Here is an image of the “Dropper” hierarchy itself.
Here is the CollectScript which has the collision issue. It was meant to play a sound when the ball was touched and disappeared. ( I’m using this script to make the GoldBall disappear. )
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
script.Parent.Transparency = 1
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
script.Sound:Play()
wait(1)
script.Parent:Remove()
end
end
end)
As for the collisiongroup script, I just have it in the script service like so.
local PS = game.PhysicsService
local Goldball = game.ServerStorage.Balls.GoldBall
local Quartzball = game.ServerStorage.Balls.QuartzBall
local Silverball = game.ServerStorage.Balls.SilverBall
PS:CreateCollisionGroup("Ball")
PS:CreateCollisionGroup("Players")
PS:CollisionGroupSetCollidable("Ball","Players",false)
PS:SetPartCollisionGroup(Goldball,"Ball")
PS:SetPartCollisionGroup(Quartzball,"Ball")
PS:SetPartCollisionGroup(Silverball,"Ball")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
player.CharacterAppearanceLoaded:Wait()
for _, p in pairs(player.Character:GetChildren()) do
if p:IsA("Part") or p:IsA("MeshPart") then
PS:SetPartCollisionGroup(p,"Players")
end
end
end)
end)
My sounds are just a small popping noise, like most games. I was wondering if maybe there was a time length minimum limit it would have to be.
I’ve tried messing with in game volume, the properties of the sound files itself as well as trying to use the sound service which I can’t seem to do correctly.
Any help and tips would be appreciated! Sorry for the dreadfully long post. I just feel the more details the better.
Also, by chance, if anyone can point me to a topic or documentation on how to merge a dropper, that would be the bees knees.
Thanks for reading!