as i said i’m having this weird problem that i’ve never seen before
when replicating a flashlight from replicated storage into the player even though the can collide is off the player really fastly jerks down and then back up i have a video if that didnt make since
robloxapp-20230205-1328202.wmv (3.0 MB)
heres the server script
game.ReplicatedStorage.EventStorage.FlashlightEvents.on.OnServerEvent:Connect(function(plr:Player)
local clone = game.ReplicatedStorage.VmStorage.FakeFlashlight:Clone()
clone.Parent = plr.Character
print(clone.Parent)
local head = plr.Character:WaitForChild(“Head”)
clone.PrimaryPart.CFrame = head.CFrame * CFrame.new(0.9,0.35,-0.2)
local weld = Instance.new(“WeldConstraint”)
weld.Parent = plr.Character
weld.Part0 = clone.PrimaryPart
weld.Part1 = plr.Character.HumanoidRootPart
clone.PrimaryPart.CFrame = plr.Character.HumanoidRootPart.CFrame
print(“Cewl”)
end)
local script
local player = game.Players.LocalPlayer
local char = player.Character
local cam = workspace.CurrentCamera
local viewmodel = game.ReplicatedStorage.VmStorage:WaitForChild(“Flashlight”):Clone() or game.ReplicatedStorage.VmStorage.Flashlight:Clone() – just incase it’s already loaded
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
local run = game:GetService(“RunService”)
local CameraCF = CFrame.new()
local swayCF = CFrame.new()
local SwayX = 3
local SwayY = 5
local equip = game.ReplicatedStorage.BoolStorage.Flashlight
local uis = game:GetService(“UserInputService”)
task.wait()
local audio = script[“Flashlight Click”]
uis.InputBegan:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.F then
flashlight()
end
end)
function flashlight()
local val = game.ReplicatedStorage.BoolStorage.StartupGui.InGui
if val.Value == false then
if equip.Value == false then
game.ReplicatedStorage.EventStorage.FlashlightEvents.on:FireServer()
changeIfSwitch()
viewmodel.Handle[“Right Arm”].Color = game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Color
viewmodel.Parent = cam
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 1
audio:Play()
equip.Value = true
run.RenderStepped:Connect(function()
if game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).Health > 0 then
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(CameraCF)
local x,y,z = rotation:ToOrientation()
swayCF = swayCF:Lerp(CFrame.new(math.sin(-y)*SwayX,math.sin(x)*SwayY,0), .2)
CameraCF = cam.CFrame
– viewmodel.PrimaryPart.Position = game.Players.LocalPlayer.Character:WaitForChild(“Torso”).Position * CFrame
viewmodel:SetPrimaryPartCFrame(player.Character:WaitForChild(“Head”).CFrame * CFrame.new(CameraCF.Rotation.X,CameraCF.Rotation.Y,CameraCF.Rotation.Z) * CFrame.new(-0.6,-0.4,0.7)*swayCF)
end
end)
else
game.ReplicatedStorage.EventStorage.FlashlightEvents.off:FireServer()
equip.Value = false
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 0
audio:Play()
end
end
end
function hideFlashlightIfDead()
if game.Players.LocalPlayer.Character:WaitForChild(“Humanoid”).Health <= 0 then
equip.Value = false
viewmodel.Parent = game.ReplicatedStorage.VmStorage[“ClonedVm’s”]
game.Players.LocalPlayer.Character:WaitForChild(“Right Arm”).Transparency = 0
end
end
function changeIfSwitch()
if game.ReplicatedStorage.BoolStorage.ThirdPerson.Switch.Value == true then
SwayX = 1
else
SwayX = 2.5
end
end
sorry i dont know how to use the format thing lol