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

How to i use remoteevents smart?

local RE =game.ReplicatedStorage:WaitForChild("RemoteEvent")
RE.OnServerEvent:Connect(function(sender, ID,Gen)
	if Gen == "Play" then
	local Plr=game.Workspace:FindFirstChild(sender.Name)
	if not Plr:FindFirstChild("Sound") then
	local Sound = Instance.new("Sound",Plr)
	Sound.SoundId = ID
	Sound.Looped = true
	Sound:Play()
	end
	if Gen == "Pause" then
	Plr:FindFirstChild("Sound")
	end
	if Gen == "Stop" then
	Plr:FindFirstChild("Sound"):Destroy()

	end
	end
end)

Just made this radio script, but it doesn't work. I made a variable called gen, that variable checks if the pause button is clicked and fired but it doesn't work please help. Like i instead of having 3 remote events just have one with just setting some variables for it??

2 comments

0

Can we see your local script as well? I don't see anything too wrong with this. Not sure why you're doing "local Plr = game.Workspace:FindFirstChild(sender.Name)" when you could just do "local Plr = sender.Character"

0

Oh thx i didn't know that

1 answer

--local script
local RE = game.ReplicatedStorage:WaitForChild("RemoteEvent")
script.Parent.Play.MouseButton1Click:Connect(function()
	if script.Parent.TextBox.TextBox.Text == "" == false then
	local Plr = game.Players.LocalPlayer
	local Asset = game.MarketplaceService:GetProductInfo(script.Parent.TextBox.TextBox.Text)
	script.Parent.SongName.Text = Asset.Name
	script.Parent.UploadedBy.Text = "Uploaded by "..Asset.Creator.Name
	RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Play")
	end
end)
script.Parent.Pause.MouseButton1Click:Connect(function()
RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Pause")
end)
script.parent.Stop.MouseButton1Click:Connect(function()
	RE:FireServer("rbxassetid://"..script.Parent.TextBox.TextBox.Text,"Stop")
	script.Parent.SongName.Text = ""
	script.parent.UploadedBy.Text = "Uploaded by nobody"
	script.Parent.TextBox.TextBox.Text = ""
end)
--ServerScript
local RE =game.ReplicatedStorage:WaitForChild("RemoteEvent")
RE.OnServerEvent:Connect(function(sender, ID,Gen)
	if Gen == "Play" then
	local Plr=game.Workspace:FindFirstChild(sender.Name)
	if not Plr:FindFirstChild("Sound") then
	local Sound = Instance.new("Sound",Plr)
	Sound.SoundId = ID
	Sound.Looped = true
	Sound:Play()
	end
	if Gen == "Pause" then
	Plr:FindFirstChild("Sound")
	end
	if Gen == "Stop" then
	Plr:FindFirstChild("Sound"):Destroy()

	end
	end
end)

3 comments

0

Im in mobile right now but look over line number 4. It doesnt make sense to check if a string is false.

0

Use if script.Parent.TextBox.TextBox.Text ~= "" then it's easier (not equal to "")

0

Oh thx

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