I wanted to make a kill sound gamepass, which means that when the buyer kills another player it plays the custom kill sound.
Unfortunately I don’t really know how to do this since i’m not really good with MarketplaceService.
I wanted to make a gui which linked up with the server with a remote event:
// LOCAL SCRIPT IN THE “USE” BUTTON
local MarketplaceService = game:GetService(“MarketplaceService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Debris = game:GetService(“Debris”)
local GamePassID = 123456789
script.Parent.MouseButton1Click:Connect(function()
local hasGamePass = false
local success, message = pcall(function() hasGamePass = MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamePassID)end)
if not success then
warn("Error while checking if player has game pass: " … tostring(message))
end
if hasGamePass then
local KillSound = Instance.new(“Sound”)
KillSound.SoundId = script.Parent.Parent.KillSoundInput.Text
-- ???
end
end)
As you can see i got lost in the local script as I don’t know what to send from one script to another and how to manage this, I also don’t know how to check if a specific player killed another one so that’s why
If anyone knows how to continue or how to make it please respond thank you.
This might work, I didn’t check it but hopefully it works:
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local GamePassID = 123456789
script.Parent.MouseButton1Click:Connect(function()
local hasGamePass = false
local success, message = pcall(function()
hasGamePass = MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, GamePassID)
end)
if not success then
warn("Error while checking if player has game pass: " .. tostring(message))
end
if hasGamePass then
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local KillSound = Instance.new("Sound")
KillSound.SoundId = script.Parent.Parent.KillSoundInput.Text
local existingDeathSound = humanoid:FindFirstChild("DeathSound")
if existingDeathSound then
existingDeathSound:Destroy()
end
KillSound.Name = "DeathSound"
KillSound.Parent = humanoid
end
end
end)
Oh i think you got it wrong I am not trying to change the death sound, I am trying to make a system where the player who owns this gamepass and inputs the audio id kills someone and this audio plays when the other person dies. Thank you
Sorry.
What are you using to kill them? Because you would have to change it in the weapon’s script that is attacking the other player
Oh i’m using custom made gun tools, I modified the script from the roblox laser gun tool
Can you give me the script? I may possibly be able to help you.
It’s a little long I’m gonna give you the main parts where the contact happends:
–/////
local function Dematerialize(character, humanoid, firstPart)
local Character2 = Tool.Parent
local Humanoid = Character2:WaitForChild(‘Humanoid’)
local Player = PlayersService:GetPlayerFromCharacter(Character)
–ragdoll.Start(character, “Hello”)
humanoid:TakeDamage(1000)
local KnockBackConstructor = ApplyKnockBack.new(character,Character2,2.5, 1)
KnockBackConstructor:Construct()
end
local function OnTouched(shot, otherPart)
local character, humanoid = FindCharacterAncestor(otherPart)
if character and humanoid and character ~= Character and not character:FindFirstChild(DEBOUNCE_TAG_NAME) and not character:FindFirstChild’ForceField’ then
local isTeammate = GLib.IsTeammate(GLib.GetPlayerFromPart(Tool), GLib.GetPlayerFromPart(Character))
if not isTeammate then
ApplyTags(humanoid)
if shot then
local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
if hitFadeSound then
hitFadeSound.Parent = humanoid.Torso
hitFadeSound:Play()
end
--shot:Destroy()
end
Dematerialize(character, humanoid, otherPart)
end
end
end
– ///////
I need the full script or all the functions will be broken.
I figured it out! Thank you so much for responding and helping
1 Like
Could you mark my reply as the solution if it helped you? Not necessary if you don’t feel it was enough help.