So basically, for example, I want to fire a projectile, if that projectile hits a player, a remote is fired which shows a GUI or something on the player that got hit’s client, if that makes sense, im kind of bad at explaining things
Event:FireClient(Player) --> Makes it send to "Player"
Event:FireAllClients() --> Sends it to ALL players
2 Likes
Some example code for an idea:
when the part is touched get hit
if hits parent is a character and the character has a player to it
fireclient using a variable for player
So all I have to do is get the victim’s name and put it as an argument in the remote?
You have to get the victim’s player object, Not the name.
local Player = game.Players.Bobby
Event:FireClient(Player) --> Fires ONLY for bobby
2 Likes
You need the victims player OBJECT, which you can get from hit,
AN ACTUAL EXAMPLE:
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.WhateverYouCallYourRemoteEvent:FireClient(plr)
end
end)
1 Like
Ohh I see, thanks!
Char limitt
1 Like
I would recommend giving yourself solutions, hand them out to other players
Can you use the player that you fired the client for on the local script side?
1 Like
You can already retrieve the player by doing
local localPlayer = game:GetService("Players").LocalPlayer
on the client
1 Like
but what if the target - rig? I just wanted to practice solo first, but there is no rig in the players.