i have a button which when clicked spawns a rocket that follows the players mouse but the rocket it only visible to the player and not everyone else how would I make it so that everyone can see it?
i’ve tried using remote events but no success
local active
local Tool = script.Parent
local rs = game:GetService("ReplicatedStorage")
local eventsfolder = rs:WaitForChild("EventsFolder")
local boomevent = eventsfolder:WaitForChild("Boom")
local moveevent = eventsfolder:WaitForChild("Moverocket")
local folder = rs:WaitForChild("Sussylocalscript")
local Rocket = folder:WaitForChild("Rocket"):Clone()
local plr = game.Players.LocalPlayer
local Debris = game:GetService('Debris')
local mouse = plr:GetMouse()
--rocketMesh.TextureId = "http://www.roblox.com/asset/?id=31601599"
local debris = game:GetService("Debris")
local swooshSound = script.Swoosh
local explosionSound = script.Explosion
local oldcurson = mouse.Icon
local vCharacter
local vPlayer
local params = RaycastParams.new(Rocket)
function blow(hit, missile)
active = false
mouse.Icon = oldcurson
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Custom"
if missile == nil then return end
if swooshSound then swooshSound:stop() end
boomevent:FireServer(missile.CFrame)
if explosionSound then explosionSound:Play() end
if missile then missile:Destroy() end
end
function fire(vTarget)
local vCharacter = plr.Character
local vHandle = vCharacter:findFirstChild("HumanoidRootPart")
if vHandle == nil then
end
mouse.Icon = "rbxassetid://12751601230"
local direction = vTarget - vHandle.Position
direction = computeDirection(direction)
local missile = Rocket:clone()
local pos = Vector3.new(939.887, 291.665, -812.581) + (direction * 10.0)
missile.CFrame = CFrame.new(pos, pos + direction) * CFrame.Angles(0, math.pi/2, 0)
local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
if vPlayer == nil then
print("Player not found")
else
if (vPlayer.Neutral == false) then -- nice touch
missile.BrickColor = vPlayer.TeamColor
end
end
local floatForce = Instance.new("BodyForce")
floatForce.force = Vector3.new(0, missile:GetMass() * 196.1, 0.0)
floatForce.Parent = missile
missile.Velocity = computeDirection(vCharacter.Humanoid.TargetPoint - missile.Position) * 20.0
if swooshSound then swooshSound:Play() end
missile.Touched:connect(function(hit) blow(hit, missile) end)
debris:AddItem(missile, 100.0)
local cam = workspace.CurrentCamera
cam.CameraSubject = missile
cam.CameraType = "Follow"
active = true
local parent = plr.Character
while(active) do
direction = computeDirection(mouse.Hit.Position - missile.Position)
missile.Velocity = direction * 150
--The below line of code wasn't in the tutorial. It's optional and just points the missile in the right direction
missile.CFrame = CFrame.new(missile.Position, missile.Position + direction) * CFrame.Angles(math.pi/2, 0, 0)
moveevent:FireServer(missile.CFrame)
task.wait()
end
end
function computeDirection(vec)
local lenSquared = vec.magnitude * vec.magnitude
local invSqrt = 1 / math.sqrt(lenSquared)
return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end
local db = true
function onActivated()
if not db then
return
end
db = false
local character = plr.Character;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
swooshSound = script:FindFirstChild("Swoosh")
explosionSound = script:FindFirstChild("Explosion")
local targetPos = humanoid.TargetPoint
fire(targetPos)
wait(0.1)
db = true
end
script.Parent.Activated:connect(onActivated)