This has been really annoying for me. When I press E on an object that has an "Interact" value, a remote event fires, as seen on here.
Local Script:
InputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if not DragTarget and Mouse.Target ~= nil then
local t = Mouse.Target
if t.Parent and t:FindFirstChild("Interact") then
if t:FindFirstChild("Interact").Value == true then
local interact = t:FindFirstChild("Interact").Parent
game.ReplicatedStorage.RemoteEvent:FireServer(interact)
end
end
end
end
end)
In the server script, the object is supposed to play a sound. What it's doing here is that when the event is fired, it checks the targets name. The next thing it does is that it changes the "current" value to the next sound. But that won't work, apparently the current value always stays at radio1, I have no idea why. When the event is fired the current value is supposed to change to the next sound (sorry if I repeated this.)
Server Script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, interact)
if interact.Parent.Name == "Radio" then
local model = interact.Parent
local radio = model.Radio
local power = model.Power
local backward = model.Backward
local forward = model.Forward
local debounce = false
local on = true
local radio1 = radio.radio01
local radio2 = radio.radio02
local radio3 = radio.radio03
local radio4 = radio.radio04
local radio5 = radio.radio05
local radio6 = radio.radio06
local radio7 = radio.radio07
local radio8 = radio.radio08
local radio9 = radio.radio09
local radio10 = radio.radio10
local current = radio1
if interact.Name == "Backward" then
if debounce == false then
debounce = true
if on == true then
if current == radio1 then current.Volume = 0 current = radio10 current.Volume = .5
elseif current == radio2 then current.Volume = 0 current = radio1 current.Volume = .5
elseif current == radio3 then current.Volume = 0 current = radio2 current.Volume = .5
elseif current == radio4 then current.Volume = 0 current = radio3 current.Volume = .5
elseif current == radio5 then current.Volume = 0 current = radio4 current.Volume = .5
elseif current == radio6 then current.Volume = 0 current = radio5 current.Volume = .5
elseif current == radio7 then current.Volume = 0 current = radio6 current.Volume = .5
elseif current == radio8 then current.Volume = 0 current = radio7 current.Volume = .5
elseif current == radio9 then current.Volume = 0 current = radio8 current.Volume = .5
elseif current == radio10 then current.Volume = 0 current = radio9 current.Volume = .5
end
backward.BrickColor = BrickColor.new("Sea green")
print(current)
wait(0.1)
backward.BrickColor = BrickColor.new("Persimmon")
end
debounce = false
end
end
if interact.Name == "Forward" then
if debounce == false then
debounce = true
if on == true then
if current == radio10 then current.Volume = 0 current = radio1 current.Volume = .5
elseif current == radio9 then current.Volume = 0 current = radio10 current.Volume = .5
elseif current == radio8 then current.Volume = 0 current = radio9 current.Volume = .5
elseif current == radio7 then current.Volume = 0 current = radio8 current.Volume = .5
elseif current == radio6 then current.Volume = 0 current = radio7 current.Volume = .5
elseif current == radio5 then current.Volume = 0 current = radio6 current.Volume = .5
elseif current == radio4 then current.Volume = 0 current = radio5 current.Volume = .5
elseif current == radio3 then current.Volume = 0 current = radio4 current.Volume = .5
elseif current == radio2 then current.Volume = 0 current = radio3 current.Volume = .5
elseif current == radio1 then current.Volume = 0 current = radio2 current.Volume = .5
end
forward.BrickColor = BrickColor.new("Sea green")
print(current)
wait(0.1)
forward.BrickColor = BrickColor.new("Persimmon")
end
debounce = false
end
end
if interact.Name == "Power" then
if debounce == false then
debounce = true
if on == true then
on = false
power.BrickColor = BrickColor.new("Persimmon")
current.Volume = 0
else
on = true
power.BrickColor = BrickColor.new("Sea green")
current.Volume = .5
end
debounce = false
end
end
end
end)
PS: No errors print out. Help would be appreciated.

4 comments
tl;dr? i couldnt wrap my head around that, very sorry
Line 23, move it outside of the OnServerEvent. Everytime the remote is fired, it sets it back to radio1.
ok now it makes sense, im an idiot. didnt notice that lol
It happens to the best of us, all the best.