我正在创建一个小声音,当您的鼠标悬停在按钮上时播放"White team"但实际上什么也没发生。我正在使用鼠标输入事件



每次鼠标离开并进入此按钮时,我都会尝试创建一个声音。代码实际上不起作用。我在本地脚本和普通脚本上尝试过这个:

script.Parent.MouseEnter:Connect(function()
local sound = script.Parent.Parent.hit
sound:Play()

end)
script.Parent.MouseEnter:Connect(function()
local soundTwo = script.Parent.Parent.hitS
soundTwo:Play()
end)
```[enter image description here][1]

[1]: https://i.stack.imgur.com/5niz4.png -- The explorer of the game (I used script and local script btw and none of them changed anything, but i do think local script would work better for a gui)

您可以尝试在代码顶部添加以下行。

if not sound.IsLoaded then sound.Loaded:Wait() end
if not soundTwo.IsLoaded then soundTwo.Loaded:Wait() end

此外,您的两个函数都适用于MouseEnter。尝试将一个更改为MouseLeave

最新更新