Hello, Im working on something that will send some data to the client via a remoteevent. for some reason nothing is happening. the localscript is inside a gui in starter gui. Ill add more details if I think of any
--client
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(songtable, songinfo, plrinvs, plr1, plr2, folder)
print('found')
end
--server and yea the prints do work
if v.plr.Value == player and v.Name == 'plr2' then
print('yes')
game.ReplicatedStorage.RemoteEvent:FireClient(v.plr.Value,songtable, songinfo, 2, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
elseif v.plr.Name == player then print(v.Name) game.ReplicatedStorage.RemoteEvent:FireClient(v.plr.Value,songtable, songinfo, 1, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
end
You can’t use a string value to fire to the player. You need to use the player instance itself. Try to find the player instance using game.Players:FindFirstChild(v.plr.Value)
After condensing the code a little, I realized that you’ve been firing to no players but a string. That’s not supposed to happen. The if conditions are strange and are seemingly hindering the code unnecessarily.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TargetRemote = ReplicatedStorage.RemoteEvent
if v.plr.Value == player and v.Name == 'plr2' then
print('yes')
TargetRemote:FireClient(v.plr.Value, songtable, songinfo, 2, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
elseif v.plr.Name == player then
print(v.Name)
TargetRemote:FireClient(v.plr.Value, songtable, songinfo, 1, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
end
--server
local player = script.Parent.Parent.Parent.Parent.Parent.Parent -- the player (game.players)
script.Parent.MouseButton1Click:Connect(function()
--local playerfolder = getplayerfolder(player)
for i,v in pairs(game.Workspace.guiparts:GetDescendants()) do
if v:IsA("ObjectValue") and v.Value == player then
playerfolder = v.Parent.Parent
break
end
end
game.ReplicatedStorage.ServerSong:Fire(playerfolder.Name, script.Parent.Name, 'multi', player)
remote = game.ReplicatedStorage.ServerSong.Event:Connect(function(folder, song, m)
print(folder..', '..playerfolder.Name, song..', '..script.Parent.Name , m)
if folder == playerfolder.Name and song == script.Parent.Name and m == 'song' then
for i,v in pairs(playerfolder:GetChildren()) do
print(v.plr.Value, v.Name, playerfolder.Name)
print('yes')
game.ReplicatedStorage.RemoteEvent:FireClient(v.Parent.plr2.plr.Value,songtable, songinfo, 2, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
game.ReplicatedStorage.RemoteEvent:FireClient(v.Parent.plr1.plr.Value,songtable, songinfo, 1, v.Parent.plr1.plr.Value, v.Parent.plr2.plr.Value, playerfolder)
remote:Disconnect()
end
elseif folder == playerfolder and song ~= script.Parent.Name then
remote:Disconnect()
end
end)
end)
heres the full script,
basically v should be a part in a folder that has an object value with a player as the value
game.ReplicatedStorage.ServerSong:Fire(playerfolder.Name, script.Parent.Name, 'multi', player)
remote = game.ReplicatedStorage.ServerSong.Event:Connect(function(folder, song, m)
This is a lot to take it, but it seems you’re sending off ‘multi’ to the ServerSong event, but then checking if that parameter value is equal to ‘song’, meaning the next lines never run and you never fire your event to the client.
If that’s not the problem, then I would be interested in seeing your ouput when running these scripts.