I made a script that create a marked spot when you press a button it would clone a part into workspace and it will then delete itself

But right now I cannot find a way to make it client for certain teams

this is what I did so far: -Gui fires it

local FakeOrder = game.ReplicatedStorage.Commands.FakeCommand
local Order = game.ReplicatedStorage.Commands.EnemySpot
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Command")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local Opened = script.Parent.Parent.Parent.OpenedVal
local Team = script.Parent.Parent.Parent.Parent.Parent.TeamColor

UIS.InputBegan:connect(function(keyCode)
	if keyCode.keyCode == Enum.KeyCode.Y then
		if Opened.Value == true then
			script.Parent.Parent.Parent.Enabled = false
			local CloneFakeOrder = FakeOrder:Clone()
			CloneFakeOrder.CFrame = CFrame.new(Vector3.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z))
			local position = CloneFakeOrder.Position
			remoteEvent:FireServer(Order, position, Team)
			script.Parent.Parent.Parent.Sound:Play()
			wait(0.1)
			Opened.Value = false
			print("done")
		end
	end
end)

Server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("Command")
local remoteEvent2 = ReplicatedStorage:WaitForChild("DeleteCommand")


remoteEvent.OnServerEvent:Connect(function(player, Order, position, Team)
	local ClonedCommand = Order:clone()
	local Command = ClonedCommand.Name
	ClonedCommand.Parent = workspace
	ClonedCommand.Position = position
	local Theam = Team.Name
	local ClohnedCommand = ClonedCommand
	remoteEvent2:FireAllClients(Theam ,ClohnedCommand)
	print("2done")
end)

a local script in starterplayerscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("DeleteCommand")

remoteEvent.OnClientEvent:Connect(function(player, Theam ,ClohnedCommand)
	if script.Parent.Parent.TeamColor == Theam then
		print("3done")
	else
		ClohnedCommand.BillboardGui:destroy()
		print("3done")
	end
end)

Any solutions?

1 comment

0

(Note: The print script is just for testing)