How would I make something happen to only one player that touches a part?

I’m trying to make a pad that speeds the music up when you touch it

When another player touches the part that speeds the music up, its sped up for me too

I’ve looked for solutions on the devforum and in the scripts of the kit I used but I just can’t make sense of them

I’m using a kit for an obby game (called Juke’s Towers of Hell) that has a bunch of different client objects. Right now I’m making my own kit for my own fan game that has the same stuff but for little towers, and want to add my own client objects to it.
here’s the link for that kit: https://www.roblox.com/library/5732647165/JToH-Tower-Creation-Kit-v5-35
here’s my fan game (I don’t recommend playing, it’s for very experienced obbyists) (it’s also not meant to be good): https://www.roblox.com/games/7123468987/The-Future#!/about

here’s my current script:

local MusicBrick = game.Workspace["zltop kit verson 3"]["client objects"]["Normal Music Speed"]
local MusicSpeed = game.Workspace["zltop kit verson 3"].music.BackgroundMusicZones.music1.Music.Sound

local function speed()
	MusicSpeed.PlaybackSpeed = 1.5
end

MusicBrick.Touched:Connect(speed)

local parts are stored here with module scripts
image

It might be hard to help me without taking a look at the kit to see how it’s formatted, but I’ll take anything that might help. Ask for any information you need because I have very blurred vision on how all this works

Verify the music is only on the client side. Have the touch detection on the local client as well. This way it will only work for that client.

https://developer.roblox.com/en-us/api-reference/function/SoundService/PlayLocalSound

I remember using the kit before to make some towers, but I don’t remember much of it. From what I remember, there should be server-sided music zones which contain the actual audio object. What if you change the speed on the client side so it won’t be replicated for anyone else?

Edit: I think I see what’s wrong with your code. It doesn’t check whether or not the person who touched it is the player. It runs for everyone when anyone touches it. Add a simple if statement to check whether or not it was the player who touched it, and it should work.

I tried that, but it still affects the whole server
This is my new code:

local MusicBrick = script.Parent
local MusicSpeed = game.Workspace["zltop kit verson 3"].music.BackgroundMusicZones.music1.Music.Sound

MusicBrick.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		MusicSpeed.PlaybackSpeed = 1.5
	end
end)

(by ‘that’ i mean the part you edited in)

I meant on a local script, check if it’s the local player. It runs for everyone because it’s either on a server-sided script or it runs when anyone touches it.

I put the same code in a local script and the mechanic itself doesn’t work

local MusicSpeed = game.Workspace["zltop kit verson 3"].music.BackgroundMusicZones.music1.Music.Sound

local plrs = game:GetService("Players")
local localPlr = plrs.LocalPlayer

MusicBrick.Touched:Connect(function(hit)
	local player = plrs:GetPlayerFromCharacter(hit.Parent)
	if player == localPlr then -- check if the player who hit the part is you and not someone else, otherwise it will trigger for everyone
		MusicSpeed.PlaybackSpeed = 1.5
	end
end)

this is what i mean

1 Like
local sound = game.Workspace.sound--CHANGE THES TO YOUR SOUND
local par = script.Parent
par.Touched:Connect(function(hit)
	if hit.Parent.Name  ==  "NAME" then--MAKE SURE TO CHANGE THES TO YOUR NAME
		local name = game.Workspace:FindFirstChild("NAME")--MAKE SURE TO CHANGE THES TO YOUR NAME
		if name then
			sound.Volume = sound.Volume + 2--Change the number to wahtever, how much volume you wannt!
		end
	end
end)```