scraping this, found solution through documentation
That’s not how you get player.
game.Workspace.Part.Touched:connect(function(hit)
--verifying its a player, prints player name to confirm
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if Player ~= nil then
proxplayer = Player
end
end)
script.Parent.ClickDetector.MouseClick:Connect(function(Player)
--[[ A Better way to do it
script.RemoteEvent:FireClient(Player,sendcode)
--]]
--fire the remote event and pass the sendcode to the local script as an argument
sendcode = "example"
if proxplayer ~= nil then
script.RemoteEvent:FireClient(proxplayer,sendcode)
end
end)
2 Likes
The note of
--verifying its a player, prints player name to confirm
is representing of the code to verify it’s a player, which does properly get the player and check to make sure it exists. The problem isn’t with checking the player it’s that the local script is not receiving the arguments when the client is fired
You’re not even firing to the client, you’re the firing character, you need to pass player object not character.
script.Parent.Touched:Connect(function(Hit)
print(Hit.Parent.ClassName, tostring(Hit.Parent)) -- This would print Model and character name, which you are doing.
if game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) ~= nil then
print(game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent).ClassName, tostring(game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent))) -- This would print Player and player name which FireClient requires.
end
end)
Please bring back your old post, but instead reply with the solution. This would help other people with the same problem.