How can I make this code visible to other players?

Now, this code I sent you only works in the client, only the players can see it, the players cannot see it, how can I make this visible to everyone?

--services
local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local GuiService = game:GetService("GuiService")

--varibles
local player = game.Players.LocalPlayer
local character = player.Character
local camera = workspace.CurrentCamera
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")

--modules
local cameraShaker = require(game.ReplicatedStorage:WaitForChild("Modules").CameraShaker)

--shake camera
local function ShakeCamera(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf
end

-- Create CameraShaker instance:
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local camShake = cameraShaker.new(renderPriority, ShakeCamera)

--vaulting
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

local vaultMoveNumber = 10
local canVault = true
local canMove = true
local vaultConnection = nil
local ledgePart = nil

local grabAnim = humanoid:LoadAnimation(script:WaitForChild("Grab"))
local grabRightAnim = humanoid:LoadAnimation(script:WaitForChild("GrabRight"))
local grabLeftAnim = humanoid:LoadAnimation(script:WaitForChild("GrabLeft"))
local grabSounds = script:WaitForChild("Sounds"):GetChildren()

--play vault sounds
local function playSound()
	local sound = grabSounds[math.random(1, #grabSounds)]:Clone()
	sound.Parent = rootPart
	sound.Volume = .15
	sound:Play()

	sound.Ended:Connect(function()
		sound:Destroy()
	end)
end

--check if part is above when tryin to vault or move
local function partCheck(ledge)
	local vaultPartCheck = workspace:Raycast(ledge.Position + Vector3.new(0, -1, 0) + ledge.LookVector * 1, ledge.UpVector * 3, raycastParams)
	if vaultPartCheck == nil then
		return true
	else
		return false
	end
end

local function vaultMoveCheck(ray, anim)
	local localPos = ray.Instance.CFrame:PointToObjectSpace(ray.Position)
	local localLedgePos = Vector3.new(localPos.X, ray.Instance.Size.Y/2, localPos.Z)
	local ledgePos = ray.Instance.CFrame:PointToWorldSpace(localLedgePos)
	local ledgeOffset = CFrame.lookAt(ledgePos, ledgePos - ray.Normal)

	if partCheck(ledgeOffset) then
		local magnitude = (ledgePos - head.Position).Magnitude
		if magnitude < 3 then
			local info = TweenInfo.new(.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
			local goal = {CFrame = ledgeOffset + Vector3.new(0, -2, 0) + ledgeOffset.LookVector * -1}
			local tween = TweenService:Create(ledgePart, info, goal)
			tween:Play()
			canMove = false
			playSound()

			--screen shake
			camShake:Start()
			local dashShake = camShake:ShakeOnce(.2, 13, 0, .5)
			dashShake:StartFadeOut(.5)

			--play anim
			if anim == "Right" then
				grabRightAnim:Play()
			elseif anim == "Left" then
				grabLeftAnim:Play()
			end

			--vault move delay
			task.delay(.35, function()
				canMove = true
			end)
		end
	end
end


--moving from left to right function(so my code isn't messy)
local function vaultMove(direction, anim)
	local moveRay = workspace:Raycast(head.CFrame.Position, head.CFrame.RightVector * direction + head.CFrame.LookVector * 8, raycastParams)
	if moveRay then
		if moveRay.Instance then
			vaultMoveCheck(moveRay, anim)
		end
	else
		local turnRay = workspace:Raycast(head.CFrame.Position + Vector3.new(0, -1, 0) + head.CFrame.RightVector * direction, head.CFrame.RightVector * -direction + head.CFrame.LookVector * 2, raycastParams)
		if turnRay then
			if turnRay.Instance then
				vaultMoveCheck(turnRay, anim)
			end
		end
	end
end

--detect if moving left or right
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if (humanoid.MoveDirection:Dot(camera.CFrame.RightVector) > .7) and not canVault and canMove then
		vaultMove(vaultMoveNumber, "Right")
	end

	if (humanoid.MoveDirection:Dot(-camera.CFrame.RightVector) > .7) and not canVault and canMove then
		vaultMove(-vaultMoveNumber, "Left")
	end
end)

--detect ledges
local function detectLedge()
	if canVault and (humanoid:GetState() == Enum.HumanoidStateType.Freefall or humanoid:GetState() == Enum.HumanoidStateType.Jumping) then
		local vaultCheck = workspace:Raycast(rootPart.CFrame.Position, rootPart.CFrame.LookVector * 5, raycastParams)
		if vaultCheck then
			if vaultCheck.Instance then			
				local localPos = vaultCheck.Instance.CFrame:PointToObjectSpace(vaultCheck.Position)
				local localLedgePos = Vector3.new(localPos.X, vaultCheck.Instance.Size.Y/2, localPos.Z)
				local ledgePos = vaultCheck.Instance.CFrame:PointToWorldSpace(localLedgePos)
				local ledgeOffset = CFrame.lookAt(ledgePos, ledgePos - vaultCheck.Normal)

				local magnitude = (ledgePos - head.Position).Magnitude
				if magnitude < 4 then
					if partCheck(ledgeOffset) then
						canVault = false

						--screen shake
						camShake:Start()
						local dashShake = camShake:ShakeOnce(.36, 12, 0, .5)
						dashShake:StartFadeOut(.5)

						--player follows this part(you dont exactly need it but it makes tweening the player when they move easier unless there is a better way to do this but idk)
						ledgePart = Instance.new("Part")
						ledgePart.Parent = workspace
						ledgePart.Anchored = true
						ledgePart.Size = Vector3.one
						ledgePart.CFrame = ledgeOffset + Vector3.new(0, -2, 0) + ledgeOffset.LookVector * -1
						ledgePart.CanQuery = false
						ledgePart.CanCollide = false
						ledgePart.CanTouch = false
						ledgePart.Transparency = 1

						--play anim and sound
						grabAnim:Play()
						playSound()

						--connection while player is on a ledge
						vaultConnection = RunService.RenderStepped:Connect(function(dt)
							rootPart.Anchored = true
							humanoid.AutoRotate = false -- so shift lock doesnt't rotate character
							rootPart.CFrame = rootPart.CFrame:Lerp(CFrame.lookAt(ledgePart.Position, (ledgePart.CFrame * CFrame.new(0, 0, -1)).Position), .25)
							humanoid:ChangeState(Enum.HumanoidStateType.Seated)
						end)
					end
				end
			end
		end
	elseif not canVault then
		canVault = true
		humanoid.AutoRotate = true
		rootPart.Anchored = false
		humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
		grabAnim:Stop()

		--check if it exists and then disconnect
		if vaultConnection then
			vaultConnection:Disconnect()
		end

		if ledgePart then
			ledgePart:Destroy()
		end
	end
end

--pc and console support
UserInputService.InputBegan:Connect(function(input, gp)
	if (input.KeyCode == Enum.KeyCode.ButtonA or input.KeyCode == Enum.KeyCode.Space) then
		detectLedge()
	end
end)

--mobile support
if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled and not UserInputService.GamepadEnabled and not GuiService:IsTenFootInterface() then
	local jumpButton = player.PlayerGui:WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("JumpButton")
	jumpButton.Activated:Connect(function()
		detectLedge()
	end)
end

You have to put it on a server script (which wouldn’t work in this case), or use RemoteFunctions/RemoteEvents to broadcast an event to all players.

What do you mean by making the code visible to other players?

If you want other players to have their cameras shake too, you would have the server send an event to all the clients through a RemoteEvent signaling them to start a camera shake.

(If a client starts the shaking have the client send an event to the server and then have the server send the event to the other clients.)

Hi, i think i have the answer to your problem. im new to dev forum btw so tell me if there is any mistakes.

if you made a remote event connected to the server then do this

Example code

for _,Player in game.Players:GetPlayers() do
       game.ReplicatedStorage.ShakeCameraForPlayer:FireClient(Player)
end

This is a climbing animation, while the character is climbing and moving left and right there, other players only see him standing there, and when the main user finishes his movement, he suddenly becomes TP in the eyes of other players. Also, I don’t know how to use removevent :confused:

I want other players to see the player’s animations and movements, not camera shake (this is a climbing script).

No they don’t see animations and character movement

Roblox automatically replicates animations from the client to the server (I was told) so it should be working. Maybe check your code for bugs and if you have a server script make sure it’s not stopping any animations.

Now, there is no data sending to the server in my code, I just don’t know how to transmit it to the server on the client and I don’t know what code to write.

To transmit it to the server you use a remote event and call

‘’
Remoteevent.FireServer
‘’

Here is a document about remote events

Thank you but I need the code because I added the event but I don’t know how to add it to the code.

I’m on my phone right now so I don’t think I can really type accurately but I’ll try

local event = game.ReplicatedStorage.Event
   event:FireServer()

   — server script 

  game.ReplicatedStorage.Event.OnServerEvent:Connect(function(player)

player.Character.Humanoid.Animator:LoadAnimation(script.myAnimNameHere):Play()

Make a script in serverscriptservice for the part that says “server script”

 
end)

This should run for all players (code may be inaccurate because I typed on phone)

If you’re using a custom humanoid make sure to give the client network ownership of the model from the server. This will allow the client to determine how the custom humanoid moves on the server and for other clients.

The default character should already have this set automatically though.

I’m so confused by the question, you want other players to see the code? Do you want everyones camera to shake?

If you simply want somebody’s camera to shake, just have an event (preferably in ReplicatedStorage) that fires all clients, such as the code snippet below:

local event = game.ReplicatedStorage.RemoteEvent --obviously name it/direct is as needed)
event:FireAllClients()

This should cause everyones camera to shake

No, you misunderstood, the player will see the camera shake anyway, but the animation and movements need to be seen by the other players. I can summarize it as follows: As soon as he starts climbing, the player has no problem, but the other players see him as stationary and see that he is not moving. When I finish climbing, the players see me as having thrown a tp.

Check if the same error occurs if you do not change the Anchored and AutoRotate property.

Thank you for replying but there is no error I’m just asking how to make other players see the main action because it works perfectly on the player but the other players or the player can’t see it on other players

I can’t read your entire code right now, but you can read this and test it.

First about the animations. Don’t set the animations in the client (Weight/Repetition). This is a headache and must be done correctly when exporting them.

Second about the teleport. If you are using a Weld, that may be the problem. Welds should normally be set by the server, otherwise you will have this teleport effect when destroying it.

Here is my problem, how do I send this to the server, it only works in the game