I’ve attempted at making a command under the name “:Watch”, it’s supposed to set the player’s camera to the target’s character, however I tried to make it in the module script, it didn’t work, I also tried making int via LocalScript connected from the Mod. Script via a remote event in Replicated Storage.
function command.exec(player: "Player model.", args: "Arguments.", RankPermission: "Admin level", cmd)
local function get_player(player_name)
local lower_player_name = string.lower(player_name)
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name:sub(1,#player_name):lower() == lower_player_name then
return player
end
end
end
local target = nil
if args[2] then target = get_player(args[2]) else target = player end
game.ReplicatedStorage.Remote:FireClient(target, player)
end
after doing “:watch Vx_ney” (My friend) nothing happens. I’ve tried everything I know how to fix this, however I couldn’t come up with a fix, so I went here, to the DevForum to ask for help or improvement or suggestions.
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
local args = message:split(" ")
local plrrank = 0
plrrank = script.Admins:FindFirstChild(player.Name).Value
for _,v in pairs(Cmds:GetChildren()) do
local cmd = require(v)
if args[1] == ":" .. cmd.info().Name and plrrank >= cmd.info().RankPerm and cmd.info().Enabled == true then
cmd.exec(player, args, plrrank, cmd, message)
require(script.AssistantModule).addLog(player.Name, message)
end
end
end)
end)
in this like the target refers to theplayer who will recieve the re and over here
you are adding another target so your are giving 1 think but the scripts wants 2 so just add another target b/w target and player in the module script.
-- MODULESCRIPT
function command.exec(player: "Player model.", args: "Arguments.", RankPermission: "Admin level", cmd)
local function get_player(player_name)
local lower_player_name = string.lower(player_name)
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name:sub(1,#player_name):lower() == lower_player_name then
return player
end
end
end
local target = nil
if args[2] then target = get_player(args[2]) else target = player end
game.ReplicatedStorage.USARYAdminRemote:FireClient(player,target)
end
return command
are you then even calling command.exec? if its not printing anything with a if then maybe its because the function isnt working. try using fire all clients and then tell me if it still prints.
Seems that you are sending a Player instance to the LocalScript, but in the local script you are dealing with the Player Instance as a Character Model, trying to get the Humanoid from the Player but the Humanoid is in Character Model
This indeed is a Player Instance:
for _, player in pairs(game.Players:GetPlayers()) do
if player.Name:sub(1,#player_name):lower() == lower_player_name then
return player -- Player Instance
end
end
target variable is holding that Player Instance: target = get_player(args[2])
You are firing the client sending the player instance not the character: game.ReplicatedStorage.Remote:FireClient(target, player)
I was right, the local script needs to be in starterplayerscripts/startercharacterscripts, I don’t know why, but I guess now it works. Thank you both for your time thought.