Why This is Happening?

  1. What do you want to achieve? Trying to do an music that everyone can hear once someone gets the target value.

  2. What is the issue? This error is showing up:

--Character is not a valid member of 'Players' "Players"
  1. What solutions have you tried so far? I tried to many things of my last topic but still din’t work.

My script:

local Player = game:GetService("Players")
local power = script.Parent
local character = script.Parent.Parent

script.Parent.Changed:Connect(function()
	if script.Parent.Value == 43 then
		local kills5 = Instance.new("Sound",Player.Character.Humanoid.Torso)
		kills5.SoundId = "rbxassetid://10636340314"
		kills5.Looped = true
		kills5.Volume = 2.2
		kills5:Play()
		Player.Character.Humanoid.WalkSpeed = 23
	end

	if script.Parent.Value == 45 then
		Player.Character.Humanoid.WalkSpeed = 25	
	end

	if script.Parent.Value == 47 then
		Player.Character.Humanoid.WalkSpeed = 27
	end

end)

What is happening?

You forgot to add .LocalPlayer to the Player variable. Also I am not sure how efficient this would be for a killstreak like system.

2 Likes

Im trying to do it in a normal script since only the player can hear if i do this on a LocalScript.

You still need to specify the Character or Player.

local Player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)

This error show up:

--Players.tutizillig.BackPack.Killstreak.Hitbox.HitHandler.Power.kills:7: attempt to index nil with character

I’m guessing that this script is in StarterCharacterScripts?

The player service also doesn’t have a Character child, you must either do a for loop or call .LocalPlayer

No, the script on parented on a tool.

Ok, but did you see the post I just sent? You must fix that
That is why the Character is not a valid member of Player shows up

The script is an server script, i can’t use LocalPlayer.

Ok then change you code to this:


local Player = game:GetService("Players")
local power = script.Parent
local character = script.Parent.Parent

script.Parent.Changed:Connect(function()
	if script.Parent.Value == 43 then
            for I,v in pairs(Player:GetChildren()) do
		local kills5 = Instance.new("Sound")
                kills5.Parent = v:WaitForChild("Torso")
		kills5.SoundId = "rbxassetid://10636340314"
		kills5.Looped = true
		kills5.Volume = 2.2
		kills5:Play()
		v:WaitForChild("Humanoid").WalkSpeed = 23
	end

	if script.Parent.Value == 45 then
		v.Humanoid.WalkSpeed = 25	
	end

	if script.Parent.Value == 47 then
		v.Humanoid.WalkSpeed = 27
	end
    end

end)

It worked but this warning show up:

--Infinite yield on possible 'Players.tutizillig:WaitForChild("Torso")'

Ok then add this right next to that line: or v.ChacterAdded:Wait()

This line?

kills5.Parent = v:WaitForChild("Torso") or v.ChacterAdded:Wait()

Yes

Limits limits limits

It din’t worked… Same error

--Infinite yield on possible 'Players.tutizillig:WaitForChild("Torso")'

Ok, remove the or statement and add a wait() either after or before the kills5.Parent line
Also put v.Character I forgot

If your game R15 or R6?
if R15 change this line:

kills5.Parent = v:WaitForChild("Torso")

to

kills5.Parent = v:WaitForChild("HumanoidRootPart")
1 Like

Like this?

wait() kills5.Parent = v:WaitForChild("Torso") v.CharacterAdded:Wait()

My game is set to R6 Character.