I'm having some problems with the skill I did, the Blaster doesn't appear in the right place

I made a skill called pure blaster:

Skill

But have some problems.

1-If i talk and press to fire the skill the blaster appears inside me (even though I’m anchoring a player so he can’t walk at the beginning of the skill)

SkillBug

2-If I jump the same thing happens

SkillJump

I already tried fix, but i dont know what is the problem

Code on Server:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PureBlaster = ReplicatedStorage.Skills.Pure.PureBlaster
local Meshes = script.Meshes
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local trainingm = require(game.ServerStorage.TrainingFiles.TrainingModule)


local function pureBlasterF(player)
if player.Character.HumanoidRootPart.Anchored == false then
 if not workspace:FindFirstChild(player.Name.." Blaster")then
	
	
	local damage = player.Stats.Mind.Value
	local usingSkill = Instance.new("BoolValue")
	usingSkill.Name = "usingSkill"
	usingSkill.Value = true
	usingSkill.Parent = player
	print("BLASTER ")
	
	
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	
	local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
	
	HumanoidRP.Anchored = true
	
	
	

	local Track =  Humanoid:LoadAnimation(script.Animation)
    Track:Play()

	
	--Hold
	local Folder = Instance.new("Folder",workspace)
	Folder.Name = player.Name.." Blaster"
	Folder.Parent = workspace
	
	Debris:AddItem(Folder,3.5)
	
	
	local PureB = Meshes:WaitForChild("PureB"):Clone()
	PureB.CFrame = Character:WaitForChild("LeftHand").CFrame
	PureB.Size = Vector3.new(2,2,2)
	PureB.Parent = Folder
	
	local PureB2 = Meshes:WaitForChild("PureB"):Clone()
	PureB2.CFrame = Character:WaitForChild("RightHand").CFrame
	PureB2.Size = Vector3.new(2,2,2)
	PureB2.Parent = Folder
	
	local weld = Instance.new("WeldConstraint")
	weld.Parent = Folder
	weld.Part0 = PureB
	weld.Part1 = Character:WaitForChild("LeftHand")
	
	local weld2 = Instance.new("WeldConstraint")
	weld2.Parent = Folder
	weld2.Part0 = PureB2
	weld2.Part1 = Character:WaitForChild("RightHand") 
	
	Debris:AddItem(PureB,1.25)
	Debris:AddItem(PureB2,1.25)	
	
	wait(0.75)

	
	local goal = {}
	goal.Size = PureB.Size + Vector3.new(9,0,0)
	local info = TweenInfo.new(0.2)
	local tween = TweenService:Create(PureB,info,goal)
	tween:Play()
	
	local goal = {}
	goal.Size = PureB2.Size + Vector3.new(9,0,0)
	local info = TweenInfo.new(0.2)
	local tween = TweenService:Create(PureB2,info,goal)
	tween:Play()

    if player:FindFirstChild("shield") then	
	  if player.shield.Value < 3 then
		 player.shield.Value = player.Shield.Value + 1
	  end  	
    else
	   local shield = Instance.new("IntValue")
	   shield.Name = "shield"
	   shield.Value = 1
	   shield.Parent = player
    end

    coroutine.wrap(function()
	      print("Entrei no shield")
		  while workspace:FindFirstChild(player.Name.." Blaster"):FindFirstChild("PureB") do
			print("Entrei no shield 2")
			wait(0.5)
		  end
		  print("Entrei no shield 3")
		  player.shield.Value = player.shield.Value - 1
		  if player:FindFirstChild("shield").Value == 0 then
			 player.shield:Destroy()
		  end
	   end)()
 
      wait(0.2)	
	
	  local BlasterP = Meshes:WaitForChild("BlasterP"):Clone()
	  local offset = Vector3.new(0,0,-1)
      BlasterP.CFrame = Character.UpperTorso.CFrame * CFrame.new(offset)
      BlasterP.Orientation = BlasterP.Orientation + Vector3.new(0,-90,0)
      BlasterP.Size = Vector3.new(1,15,15)
      BlasterP.Anchored = true
      BlasterP.Parent = Folder 

    
	local goal = {}
	goal.Size = BlasterP.Size + Vector3.new(100,0,0)
	goal.CFrame = BlasterP.CFrame * CFrame.new(-50,0,0)
	local info = TweenInfo.new(0.2)   
	local tween = TweenService:Create(BlasterP,info,goal)
	tween:Play()
	
	
	   coroutine.wrap(function()
		  for count = 1,5,1 do
	      BlasterP.Transparency = BlasterP.Transparency + 0.2
	      wait(0.2)
	      end
	   end)()    

       
	
	  local transp = 0.1
	  wait(0.5)
	  HumanoidRP.Anchored = false
	  for count = 1,10,1 do
	     BlasterP.ParticleEmitter.Transparency = NumberSequence.new(transp,transp)
	     wait(0.2)
	     transp = transp + 0.1
	  end
	
	   
    Debris:AddItem(usingSkill,1.0)	   	
 end	
end
end


PureBlaster.OnServerEvent:Connect(pureBlasterF)

Code on client:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PureBlaster = ReplicatedStorage.Skills.Pure.PureBlaster
local UltraShield = ReplicatedStorage.Skills.UltraShield:WaitForChild("UltraShield")
mouse.KeyDown:connect(function(key)
	if key == "e" then
		print("eeee")
		PureBlaster:FireServer()
	elseif key == "f" then //Ignore that, is another skill 
		print("ffff")
		UltraShield:FireServer()
	end
end)

So if anyone can helpme, iam trying a lot, but is hard to fix, i dont have any idea.

Latency is the problem.

You appear to be sending the blaster from a position they used to be at. This means there will be some desync of where the blaster will appear. You can “bypass” this by telling every client to send the ray from where a client is on their screen, but continue to do hit detection on the server.

Hmm, okay but How do that ? I really dont have idea

Just use :FireClient and pass each client individually the person who you want to draw the ray from. Don’t send the request to whoever made the request to send the ray, just have them render the ray.

Here is a chart to demonstrate the logic.

Player1 sends a request to the server. The server sends a request for each player (except Player1) to render the ray. All of the clients will then draw the ray.

1 Like

Why except player1 If player1 Will use the skill ? That made no Sense for me

  1. Source Player activates the skill
    i. Sends a remote event to server
    ii. Make the visual effects for the skills

  2. Server recieves remote event from Source Player
    i. Send a remote event to every player to make the visual effect (except for the Source Player, he already made the visual effects, remember?)
    ii. Handle damage and other serversided logic

  3. Other Players recieve the remote event from Server
    i. Make visual effects for the skills

We are having the clients draw the skills instead of the server. This means that the server won’t see any visual effects, but it should still handle hitboxes and damage. Since the visual effects are being made on the clients, they will appear smoother and the effects will be in the positions each client thinks is right, so it should always appear perfect regardless of latency.

Os that a good Idea? I never saw no one doing that, like If player computer isnt that good

What ??, Why you deleted Man ?