Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a custom admin script that affects other people?

I would like a command that will focus the camera on someone. I know that camera bit of scripting but not how to make it affect another player. For example, kill player.Name where player.Name Is another person in the game

admins = {["Player1"] = true, ["iGlaciem"] = true}
player = script.Parent.Parent
mouse = player:GetMouse()
camera = game.Workspace.CurrentCamera

function onChatted(msg)
	if admins["Player1"] == true or admins["iGlaciem"] == true then
		if msg == "view".. "" then
			
		end
	end
end

player.Chatted:connect(onChatted)

1 comment

1

Here is a good tutorial by ROBLOX to help you. I do not feel like answering your question because all the information you need is on here: http://wiki.roblox.com/index.php?title=Chat_commands

1 answer

✓ Accepted answer

The camera object is only accessible from the client. You will have to setup a RemoteEvent, and then use the FireClient function to send arguments to the client. Use a localscript to connect this RemoteEvent, and do the camera manipulation from there.

You can setup a PlayerAdded event, along with a Chatted event to recieve when any player in the game talks.

  • Place a RemoteEvent in ReplicatedStorage.

Server script

local admins = {["Player1"] = true, ["iGlaciem"] = true, ["Goulstem"] = true}
local re = game.ReplicatedStorage.AdminRemote --This is your remote

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if admins[plr.Name] then
			if msg:sub(1,5):lower() == "view;" then
				local target = msg:sub(6);
				re:FireClient(plr,target);
			end
		end
	end)
end)

LocalScript

local plr = game.Players.LocalPlayer;
local cam = workspace.CurrentCamera;
local re = game.ReplicatedStorage.AdminRemote;

re.OnClientEvent:Connect(function(target)
	targ = game.Players[target].Character.HumanoidRootPart;
	cam.CameraSubject = targ;
	cam.CoordinateFrame = CFrame.new(
		(targ.CFrame * CFrame.new(0,5,-5)).p,
		targ.CFrame
	)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.