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

How to i use remoteevents smart?

Asked by 4 years ago
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??

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" cruizer_snowman 117 — 4y
0
Oh thx i didn't know that dr6g0nb0y 27 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
--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)
0
Im in mobile right now but look over line number 4. It doesnt make sense to check if a string is false. cruizer_snowman 117 — 4y
0
Use if script.Parent.TextBox.TextBox.Text ~= "" then it's easier (not equal to "") bnxDJ 57 — 4y
0
Oh thx dr6g0nb0y 27 — 4y
Ad

Answer this question