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 =)
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!