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