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

I'm having a problem with click detectors in characters?

Asked by 6 years ago

Hello helpers!

I'm having a bit of trouble with my Roblox Lua at the moment. I am trying to create a feature that enables the user to click and select another player.So far, the only way I can see of doing this is a clickDetector and a remote event. (With filtering enabled)

The Scripts are being placed as so:

->StarterCharacterScripts
    ->playerClickDetector
    ->LocalScript               (Used to FireServer() when detector is clicked)
    ->Script                    (Runs the function on click)

localScript:

clickDetector = script.Parent:WaitForChild("playerClickDetector");
local myplayerName = script.Parent.Name;
clickDetector.MouseClick:connect(function(player)
    print("clicked");
    game.Workspace.playerClicked:FireServer(player, myplayerName);
end)

Script

local targetPlayer;
local targetPlayerName;
local targetPlayerHealth;


game.Workspace:WaitForChild("playerClicked").OnServerEvent:connect(function(player, playerName)
    print(player.Name);
        print(playerName);

end)

If you could help me I would be extremely grateful! I am still looking for a solution, and "trial and error'ing" anything I can think of.

All the best, CiarĂ¡n =)

0
the click detector should be in the player's character Viking359 161 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I found a solution using raycasting, if anyone has any similar problems and would like to see my code, feel free to pop me a message!

Ad

Answer this question