Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

trying to add local hitsounds to weapons Kit- SoundID not valid member of workspace?

I'm attempting to add hitsounds upon damaging player (ala quake,tf2 etc) to the roblox weapons kit and running into what is likely a basic error: Here's the weapons kit for reference https://developer.roblox.com/en-us/articles/weapons-kit

In WeaponsGUI there's existing code which is called to indicate damage numbers to the client, which resides under replicatedstorage/weaponsystem/Libraries/ I've piggy backed off this logic and added the following lines (between start hitsound code/end hitsound code) to try and play a hitsound locally for the client.

function WeaponsGui:OnHitOtherPlayer(damage, humanoidHit) -- show hit indicator, then fade 
	self.hitMarker.ImageTransparency = 0
	local tweenInfo = TweenInfo.new(0.8)
	local goal = {}
	goal.ImageTransparency = 1
	local tween = TweenService:Create(self.hitMarker, tweenInfo, goal)
	tween:Play()

	DamageBillboardHandler:ShowDamageBillboard(damage, humanoidHit.Parent:FindFirstChild("Head"))
	
	--start hitsound code--
	local SoundService = game:GetService("SoundService")
	local sound = Instance.new("Sound", game.Workspace)
	sound.SoundID = "rbxassetid://4868633804"
	SoundService:PlayLocalSound(sound)
	
	----end hitsound code ---
end

However the following error occurs: SoundID is not a valid member of Sound "Workspace.Sound". This is probably super simple, but as a beginner I'm not grasping what the proper references would be with this structure, and haven't found folks running into a similar issue.

Also the sound file itself currently is parked under StarterGUI- do I need to move the actual sound file somewhere else?

Appreciate any pointers, thanks!

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.