local sound = script.BiomeA function onTouched(Player) sound:Clone().Parent=Player Player.BiomeA:Play() end script.Parent.Touched:connect(onTouched)
Once the player touches the brick it should clone sound to player, play it and never again, till he touches another brick that stops the sound.
And what it does is just plays on the brick when i touch it and spams the sound inside and i can't even find where sound clones not even in brick... problem ? ;-;
Try this on ur own studio paste this script in a brick and in the script, put a sound named BiomeA and a sound u want then watch what happens when u touch the brick the sound is weird spams alot and cannot be found anywhere... whats wrong >????
Ah i found that it pastes it into the players head hands torso etc... but i want to only do it once so it pastes into him locally and only he can hear it no one else
Your script has a few problems.
To get the player, let's use the GetPlayerFromCharacter
method.
-- Regular Script local sound = script.BiomeA function onTouched(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then -- Do Stuff end end script.Parent.Touched:connect(onTouched)
A Debounce
is used to stop code from playing multiple times in a row.
-- Regular Script local sound = script:WaitForChild("BiomeA") local Debounce = false function onTouched(part) if Debounce then return end Debounce = true local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then -- Do Stuff end wait(2)-- Modify Debounce = false end script.Parent.Touched:connect(onTouched)
Now let's just throw your code in there,
-- Regular Script local sound = script:WaitForChild("BiomeA") local Debounce = false function onTouched(part) if Debounce then return end Debounce = true local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then local SoundCopy = sound:Clone() SoundCopy.Parent = plr SoundCopy:Play() end wait(2) Debounce = false end script.Parent.Touched:connect(onTouched)
That should do it. Hope I helped.
Good Luck!