#I have a script that should emit particles once i touch a part, it doesn't .

27 messages · Page 1 of 1 (latest)

merry ginkgo
#

no errors either

#

trying to understand why it doesnt work i kept changing the script

#

see the same script also played a sound and it always played so there ws no reason the particles wouldnt emit

#

i tried removing the sound completely thinking it was the problem, from the workspace from the script even copy pasting the same script without a mention of the sound and adding prints to show the status of the script

#

the sound still played

#

the prints never got printe and theres no erros

#

even just a simple print hellow world at the very start doesnt print??

#

print("hello world")

local DataStoreService = game:GetService("DataStoreService")
local GemsStore = DataStoreService:GetDataStore("GemsStore")
local sound = script.Parent.Sound
local particleemit = script.Parent.ParticleEmitter
print("success0")

function savePlayerData(player)
    local leaderstats = player:FindFirstChild("leaderstats")
    if leaderstats then
        local Gems = leaderstats:FindFirstChild("Gems")
        if Gems then
            GemsStore:SetAsync(player.UserId .. "_Gems", Gems.Value)
        end
    end
end
print("success1")

game.Players.PlayerAdded:Connect(function(player)
    for _, Gem in pairs(game.Workspace.GemGiver:GetChildren()) do
        Gem.Touched:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid") then
                local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                
                print("success2")

                local GemNumber = tonumber(Gem.Name)
                
                print("success3")

                if player.leaderstats.Gems.Value < GemNumber then
                    player.leaderstats.Gems.Value = GemNumber                
                    if not sound.IsPlaying then
                        print("Success4")
                        sound:Play()
                        print("success5")
                        particleemit:Emit(50)
                        print("success6")

                    end



                end

            end
        end)
    end
    
    print("success7")

end)

i tried printing at every stage of the script to see what happens

#

it just keeps on loping 2 3 2 3 2 3 even after i touched the part

plush topaz
#

because you have no debounce time set

#

so its looping since your character is moving on it

hushed zenith
supple fiber
hushed zenith
#

oh

#

didnt even read the code

#

My mind is the code

supple fiber
#

pro

hushed zenith
#

had no reason to read it i wouldnt understand look at how it looks on mobile

merry ginkgo
#

doent work

merry ginkgo
#

but like the looping isnt a problem, how does it not go through the sound:play() part and still play it

#

like the portion of the script after the constant looping works