Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a way I can change this LocalScript into a regular Script?

This seems like a basic question, but still - I want to make this a script and not a LocalScript so that everyone can hear the sound, not just the player clicking it.

function PlaySound( )
script.Parent.Parent.Horn: Play( )
end
script.Parent.MouseButton1Click:connect (PlaySound)

2 comments

0

Turn off RespectFilteringEnabled so others can hear it. And don't have the spaces. And use local functions.

0

Alright, thanks

1 answer

Never trust the client. Use a RemoteEvent instead for better gameplay. I don't think you would let exploiters play their sounds so everyone can hear it.

SERVERSCRIPT

local Event = Instance.new("RemoteEvent");
Event.Name = "Sound Event";
Event.Parent = game:GetService("ReplicatedStorage");

Event.OnClientEvent:Connect(function(Player, check)
if check == "PLAY_SONG_EVENT" then
local h = Instance.new("Sound")
h.Parent = Player:WaitForChild("PlayerGui")
h:Play()
-- do other things if you want to, as this is only an example.

LOCALSCRIPT

local Event = game:GetService("ReplicatedStorage"):WaitForChild("Sound Event")
Event:FireAllClients("PLAY_SONG_EVENT")

This discussion is preserved as it was. New answers, comments, and votes are closed.