So, im making a game like PLS DONATE, but i am having an issue, first off, my remote event “Server —> Client” for playing audio on the client using an server-sided script, doesn’t work, and shows "attempt to index nil with ‘Play’, however, the audio exists before i even claim a booth!
There is another issue, with MainGui being nil in PlayerGui, and it still exists before i even claim a booth, i use that to display error messages on the client.
Scripts:
Server-sided Script:
script.Parent.ClaimBooth.Triggered:Connect(function(player)
local remotes = game.ReplicatedStorage.Remotes
print(player.Values.HasStand.Value)
if player.Values.HasStand.Value == false then
local audioClaim = game.ReplicatedStorage.Audios.ClaimBooth
remotes.audioRemote:FireClient(player, audioClaim)
script.Parent.Owner.Value = player.UserId
player.Values.HasStand.Value = true
script.Parent.ClaimBooth.Enabled = false
else
local errormsg = player.PlayerGui.MainGui.Error
local audioError = game.ReplicatedStorage.Audios.Error
remotes.audioRemote:FireClient(player, audioError)
remotes.errorRemote:FireClient(player, "You cannot claim a booth when you already claimed one!")
end
end)
LocalScript for “Server —> Client” remotes
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local errorEvent = ReplicatedStorage.Remotes:WaitForChild("errorRemote")
local audioEvent = ReplicatedStorage.Remotes:WaitForChild("audioRemote")
local function errortext(player, text)
local errormsg = player.PlayerGui.MainGui.Error
errormsg.Text = text
errormsg.Visible = true
wait(5)
errormsg.Visible = false
end
errorEvent.OnClientEvent:Connect(errortext)
local function playAudio(player, audio)
audio:Play()
end
audioEvent.OnClientEvent:Connect(playAudio)
Hope yall can help me!
