Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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.

1function PlaySound( )
2script.Parent.Parent.Horn: Play( )
3end
4script.Parent.MouseButton1Click:connect (PlaySound)
0
Turn off RespectFilteringEnabled so others can hear it. And don't have the spaces. And use local functions. User#19524 175 — 6y
0
Alright, thanks FriendBandsX 14 — 6y

1 answer

Log in to vote
0
Answered by
Syclya 224 Moderation Voter
6 years ago
Edited 6 years ago

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

01local Event = Instance.new("RemoteEvent");
02Event.Name = "Sound Event";
03Event.Parent = game:GetService("ReplicatedStorage");
04 
05Event.OnClientEvent:Connect(function(Player, check)
06if check == "PLAY_SONG_EVENT" then
07local h = Instance.new("Sound")
08h.Parent = Player:WaitForChild("PlayerGui")
09h:Play()
10-- do other things if you want to, as this is only an example.

LOCALSCRIPT

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

Answer this question