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 5 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.

function PlaySound( )
script.Parent.Parent.Horn: Play( )
end
script.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 — 5y
0
Alright, thanks FriendBandsX 14 — 5y

1 answer

Log in to vote
0
Answered by
Syclya 224 Moderation Voter
5 years ago
Edited 5 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

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")
Ad

Answer this question