Hello. I’ve been having several problems with this radio system I’m making. I’ve provided the scripts and videos below.
First of all, when my mouse hovers over the volume trigger (ClickDetector), I can change the volume via scrolling just fine, but when my mouse stops hovering over the trigger, I’m still able to change the volume even if I’m not hovering over it.
Second, if I hover my mouse over the volume trigger several times and I happen to scroll, the volume and the orientation get changed a bigger amount as if the function was fired several times at the same time.
A server script inside the radio model:
VolumeTrigger.MouseHoverEnter:Connect(function(Player)
local HintGui = Player.PlayerGui:FindFirstChild("Hint")
HintGui.TextLabel.Text = "Increase/Decrease volume (Scroll)"
HintGui.TextLabel.Visible = true
if On == true then
HoveringEvent:FireClient(Player)
ScrollUp.OnServerEvent:Connect(function(Player)
if Sound.Volume < 1 then
VolumeKnob.CFrame = VolumeKnob.CFrame * CFrame.Angles(math.rad(5), 0, 0)
Sound.Volume = Sound.Volume + 0.02
print(VolumeKnob.Orientation.X)
end
end)
ScrollDown.OnServerEvent:Connect(function(Player)
if Sound.Volume > 0 then
VolumeKnob.CFrame = VolumeKnob.CFrame * CFrame.Angles(math.rad(-5), 0, 0)
Sound.Volume = Sound.Volume - 0.02
print(VolumeKnob.Orientation.X)
end
end)
end
end)
A client script in StarterCharacterScripts:
local HoveringEvent = game.ReplicatedStorage.HoveringEvent
local ScrollUp = game.ReplicatedStorage.ScrollUp
local ScrollDown = game.ReplicatedStorage.ScrollDown
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
HoveringEvent.OnClientEvent:Connect(function()
Mouse.WheelForward:Connect(function()
ScrollUp:FireServer()
end)
Mouse.WheelBackward:Connect(function()
ScrollDown:FireServer()
end)
end)
Any help would be appreciated.