my script here is supposed to send the id from an input a player made to a radio that plays that id, however the input keeps coming in as the player, i don’t know why this is happening, can someone explain this
local script:
local play = script.Parent.Play
local stop = script.Parent.Stop
local player = game.Players.LocalPlayer
local frame = script.Parent:WaitForChild("Frame")
frame:WaitForChild("Play").MouseButton1Click:connect(function()
local input = tonumber(frame:WaitForChild("Input").Text)
if input then
play:FireServer(player, input)
end
end)
frame:WaitForChild("Stop").MouseButton1Click:connect(function()
stop:FireServer(player)
end)
server script:
local play = script.Parent.Play
local stop = script.Parent.Stop
play.OnServerEvent:Connect(function(player, input)
local character = player.Character
local radio = character:WaitForChild("Radio")
print(input)
print(player)
radio.Music:Stop()
radio.Music.SoundId = "http://www.roblox.com/asset/?id="..input
radio.Music:Play()
end)
local player = game.Players.LocalPlayer
local parent = script.Parent
local play = parent.Play
local stop = parent.Stop
local frame = parent.Frame
local playBtn = frame.Play
local stopBtn = frame.Stop
local inputBox = frame.Input
playBtn.MouseButton1Click:Connect(function()
local input = tonumber(inputBox.Text)
if input then
play:FireServer(input)
end
end)
stopBtn.MouseButton1Click:Connect(function()
stop:FireServer()
end)
local parent = script.Parent
local play = parent.Play
local stop = parent.Stop
play.OnServerEvent:Connect(function(player, input)
local character = player.Character
local radio = character:WaitForChild("Radio")
radio.Music:Stop()
radio.Music.SoundId = "rbxassetid://"..input
radio.Music.Loaded:Wait()
radio.Music:Play()
end)
When you fire the server from a client the player instance belonging to the client which fired the server is automatically sent to the server (passed as an implicit argument to the :FireServer() call).