I’m trying to make some sort of system where there (when activated) is a box around each player in the game apart from the localplayer, when this box is made it’s supposed to be able to be clicked by the localplayer and the name of that player would be put into the localplayer’s gui.
The thing is that when i’m clicking the part that’s on the player(s) character it doesnt print anything or work at all. I need some help with this.
Clicking Script: (Server)
script.Parent.MouseClick:Connect(function(plr)
print("Clicked")
local selectingPlayer = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)
game.ReplicatedStorage.MCI.Remotes:WaitForChild("Select"):FireClient(plr, selectingPlayer)
end)
Local Script:
local gui = script.Parent
local plr = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local MainFrame = script.Parent.MainFrame
local TopBar = MainFrame:WaitForChild("TopBar")
local Camera = workspace:WaitForChild("Camera")
local DragMousePosition
local FramePosition
local Draggable = false
TopBar.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
Draggable = true
DragMousePosition = Vector2.new(input.Position.X, input.Position.Y)
FramePosition = Vector2.new(MainFrame.Position.X.Scale, MainFrame.Position.Y.Scale)
end
end)
TopBar.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
Draggable = false
end
end)
UserInputService.InputChanged:Connect(function(input)
if Draggable == true then
local NewPosition = FramePosition + ((Vector2.new(input.Position.X, input.Position.Y) - DragMousePosition) / Camera.ViewportSize)
MainFrame.Position = UDim2.new(NewPosition.X, 0, NewPosition.Y, 0)
end
end)
MainFrame.SelectionButton.MouseButton1Click:Connect(function()
if MainFrame.SelectTxt.Text == "Select" then
MainFrame.SelectTxt.TextColor3 = Color3.fromRGB(255, 175, 62)
MainFrame.SelectTxt.Text = "Selecting"
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name ~= plr.Name then
local partThing = game:GetService("ReplicatedStorage").MCI.Model.MCI:Clone()
local weld = Instance.new("WeldConstraint")
weld.Parent = v.Character
weld.Part0 = partThing
weld.Part1 = v.Character.HumanoidRootPart
partThing.Position = v.Character.HumanoidRootPart.Position
partThing.Orientation = Vector3.new(v.Character.HumanoidRootPart.Orientation.X, v.Character.HumanoidRootPart.Orientation.Y - 90, v.Character.HumanoidRootPart.Orientation.Z)
partThing.CP.Position = v.Character.HumanoidRootPart.Position
partThing.CP.Orientation = Vector3.new(v.Character.HumanoidRootPart.Orientation.X, v.Character.HumanoidRootPart.Orientation.Y - 90, v.Character.HumanoidRootPart.Orientation.Z)
partThing.Parent = v.Character
end
end
else
MainFrame.SelectTxt.TextColor3 = Color3.fromRGB(81, 109, 39)
MainFrame.SelectTxt.Text = "Select"
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name ~= plr.Name then
v.Character.MCI:Destroy()
end
end
end
end)
game.ReplicatedStorage.MCI.Remotes:WaitForChild("Select").OnClientEvent:Connect(function(plr, selected)
print("Ran function")
MainFrame.PlayerName.Text = selected.Name
MainFrame.SelectTxt.TextColor3 = Color3.fromRGB(109, 51, 51)
MainFrame.SelectTxt.Text = "Unselect"
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name ~= plr.Name then
v.Character.MCI:Destroy()
end
end
end)
The box’s initial setup:
Could anyone please help me resolve this issue? Thank you.