So I was scripting a part that would clone welds from Replicated Storage onto the player’s character. However, when I look at other player’s character, the welds are only visible for themselves. Not the rest of the server.
you need to do the cloning on the server rather than in a local script, remember that because of Filtering enabled changes on the client don’t replicate to the server, for example you could use a remote event to do this task like this
--in a local script
local remoteEvent = --put a remote event here
remoteEvent:FireServer()--fire the server when you want to weld
--in a server script
remoteEvent.OnServerEvent:Connect(function(player)
--do the cloning here
end)
Will this work if this script is inside a part? Pretty much what I’m trying to do is that if you touch a certain part, welds will be cloned to the character.
yh then just use the touched event on the server in a script, and are you using a local script to do this?
No, regular scripts. But the functions that include animations and keybinds are all local scripts. However, the script that includes the welding is a regular script, not a local script. So I think this might work.
you do the welding in a regular script? and can you send the code.
Actually, it’s very complicated. The touched event triggers the scripts inside of the touched event script. One of these scripts (Which is a local script) finds the weld model from Replicated Storage and clones it to the player.
yeah you need to move the touched event script to a regular script for the welds to be visible to all players.
In the part, do you need to add a remote event object for this to work?
Also do you want me to insert the Touched event script along with the actual welding script?
no you can do it on the server like this:
local part = --put the part here
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
--do the cloning of the welds to the character
end
end)
you can also check if the character is already welded b4 you do the script
the remote event is not necessary,just use this is a normal script (server that is)
The character will not already be welded tho. I need players to manually get the welds. Pretty much like some sort of gear in the arms and legs.
Also here is the script–
local config = script.Parent.Configuration
script.Parent.Touched:connect(function(part)
if part.Parent and game:GetService(‘Players’):GetPlayerFromCharacter(part.Parent) then
local player = game:GetService(‘Players’):GetPlayerFromCharacter(part.Parent)
if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then
local Player = game.Players:GetPlayerFromCharacter(part.Parent)
if Player then
for n,i in pairs(script:GetChildren()) do
if not Player.Backpack:findFirstChild(i.Name) then
i:clone().Parent = Player.Backpack
end
end
end
end
end
end)
just put this touched script on a regular script and it should work
It is on a regular script. Its just that the welding is in another script that is a Local Script. However, that script is important cuz it contains animations and keybinds.
Here is the script containing welds and keybinds.
repeat
wait()
until game.Players.LocalPlayer.Character
local Character = game.Players.LocalPlayer.Character
local Torso = Character.Torso
local HumanoidRootPart = Character.HumanoidRootPart
wait(2)
local Speed = 100
local Force = 25000
local CastSpeed = 5
local RecoilTime = 1
local RightGoal = CFrame.new()
local LeftGoal = CFrame.new()
local RightGoalLocal = CFrame.new()
local LeftGoalLocal = (CFrame.new())
local RightGoalTarget, LeftGoalTarget = nil, nil
local Gas = false
local DriftEnabled = false
local gasGui = script.GasGui
gasGui.Parent = game.Players.LocalPlayer.PlayerGui
local capGas = 6000
local gasCount = 6000
print(gasCount … " / " … capGas)
updateGasDisplay = function()
gasGui.gasCount.Text = "Gas: " … gasCount … " / " … capGas
end
updateGasDisplay()
local DriftRight = false
local DriftLeft = false
local JumpRecoil = 0
local Stalling = false
local StallingDistance = 0
local StallingDirectionDown = false
local StallingDirectionUp = false
local Anim = Character.Humanoid:LoadAnimation(script.Grapple)
local LAnim = Character.Humanoid:LoadAnimation(script.LGrapple)
local RAnim = Character.Humanoid:LoadAnimation(script.RGrapple)
local B1 = Character.Humanoid:LoadAnimation(script.Break1)
local B2 = Character.Humanoid:LoadAnimation(script.Break2)
local hatsfixed = {}
local MassUpdate = function(child)
if child and child:IsA(“StringValue”) then
return
end
for n,i in pairs(hatsfixed) do
if i == child then
return
end
end
local Mass = 0
for n,i in pairs(Character:GetChildren()) do
if i:IsA(“Part”) then
Mass = Mass + i:GetMass()
else
if i:IsA(“Hat”) then
hatsfixed[#hatsfixed + 1] = i
i.Parent = game.Lighting
i.Handle.FormFactor = “Custom”
i.Handle.Size = Vector3.new(0.2, 0.2, 0.2)
i.Parent = Character
end
end
end
end
local Weld_Ref = game.ReplicatedStorage.RS.newAPGearTestGun
for n,i in pairs(Weld_Ref.Welds[“3DMG”]:GetChildren()) do
local part = i:clone()
part.Anchored = false
part.CanCollide = false
part.Parent = Character
local weld = Instance.new(“ManualWeld”, part)
weld.Part0 = Torso
weld.Part1 = part
weld.C1 = i.CFrame:inverse() * Weld_Ref.Torso.CFrame
end
local RightFirePosition = CFrame.new(1.05001497, -0.824505806, -0.600113869)
local LeftFirePosition = CFrame.new(-1.04998493, -0.824505806, -0.600113869)
local Velocity = Instance.new(“BodyVelocity”)
Velocity.Name = “Velocity”
Velocity.P = 5000
Velocity.maxForce = Vector3.new()
Velocity.Parent = HumanoidRootPart
local Rotation = Instance.new(“BodyGyro”)
Rotation.Name = “Rotation”
Rotation.P = 5000
Rotation.maxTorque = Vector3.new()
Rotation.D = 500
Rotation.Parent = HumanoidRootPart
local RGrappleBool = Instance.new(“BoolValue”, Character)
RGrappleBool.Name = “Right Grapple”
RGrappleBool.Value = false
local RGoalVal = Instance.new(“Vector3Value”, RGrappleBool)
RGoalVal.Name = “RightGoal”
local LGrappleBool = Instance.new(“BoolValue”, Character)
LGrappleBool.Name = “Left Grapple”
LGrappleBool.Value = false
local LGoalVal = Instance.new(“Vector3Value”, LGrappleBool)
LGoalVal.Name = “LeftGoal”
local GrappleBin = Instance.new(“Model”, workspace.CurrentCamera)
GrappleBin.Name = “Grapples”
game.Players.LocalPlayer:GetMouse().TargetFilter = GrappleBin
local RightGrapple = Instance.new(“Part”, GrappleBin)
RightGrapple.Name = “Right Grapple”
RightGrapple.BrickColor = BrickColor.new(“Really black”)
RightGrapple.Anchored = true
RightGrapple.FormFactor = Enum.FormFactor.Custom
RightGrapple.Transparency = 1
RightGrapple.CanCollide = false
local RightMesh = Instance.new(“BlockMesh”, RightGrapple)
RightMesh.Scale = Vector3.new(0.05, 0.05, 1)
local LeftGrapple = Instance.new(“Part”, GrappleBin)
LeftGrapple.Name = “Left Grapple”
LeftGrapple.BrickColor = BrickColor.new(“Really black”)
LeftGrapple.Anchored = true
LeftGrapple.FormFactor = Enum.FormFactor.Custom
LeftGrapple.Transparency = 1
LeftGrapple.CanCollide = false
local LeftMesh = Instance.new(“BlockMesh”, LeftGrapple)
LeftMesh.Scale = Vector3.new(0.05, 0.05, 1)
local Frl = Instance.new(“Part”, Character)
Frl.Name = “FakeRL”
Frl.Size = Vector3.new(1, 2, 1)
Frl.Transparency = 1
Frl.BottomSurface = “Smooth”
Frl.TopSurface = “Smooth”
Frl.CanCollide = false
local FrlWeld = Instance.new(“ManualWeld”, Frl)
FrlWeld.Part0 = Character[“Right Leg”]
FrlWeld.Part1 = Frl
local Fll = Instance.new(“Part”, Character)
Fll.Name = “FakeLL”
Fll.Size = Vector3.new(1, 2, 1)
Fll.Transparency = 1
Fll.BottomSurface = “Smooth”
Fll.TopSurface = “Smooth”
Fll.CanCollide = false
local FllWeld = Instance.new(“ManualWeld”, Fll)
FllWeld.Part0 = Character[“Left Leg”]
FllWeld.Part1 = Fll
local Keys = {}
local Keys2 = {}
local leftGrappleOn = false
local rightGrappleOn = false
local cannotGrappleOn = {Baseplate = true, Hill1 = true, Hill2 = true, Hill3 = true, Hill4 = true, Hill5 = true, hill = true, ground = true, path = true, flat = true, BasePlate = true}
local lastGroundGrapple = tick()
local function CastRightGrapple(Goal,Part)
Keys2[“e”] = nil
local Point = Vector3.new()
local LoopNo = 0
RightGrapple.Transparency = 0
local Goal2 = Goal.p
repeat
game:GetService(“RunService”).RenderStepped:wait()
if not Part then break end
if not Part.Parent then break end
Goal2 = (RightGoalTarget.CFrame*(RightGoalLocal:inverse())).p
LoopNo = LoopNo+1
local FirePos = (HumanoidRootPart.CFrameRightFirePosition).p
local Progression = LoopNo/((Goal2-FirePos).magnitude/CastSpeed)
if Progression > 1 then Progression = 1 end
local Point = FirePos+(Goal2-FirePos)Progression
RightGrapple.Size = Vector3.new(1, 1, (FirePos-Point).magnitude)
RightGrapple.CFrame = CFrame.new(FirePos+(Point-FirePos)/2, Goal2)
until(Point-Goal2).magnitude < 5 or not Keys[“e”]
Keys2[“e”] = true
if not Keys[“e”] then Keys2[“e”] = false return false end
return true
end
local function CastLeftGrapple(Goal,Part)
Keys2[“q”] = nil
local Point = Vector3.new()
local LoopNo = 0
LeftGrapple.Transparency = 0
local Goal2 = Goal.p
repeat
game:GetService(“RunService”).RenderStepped:wait()
if not Part then break end
if not Part.Parent then break end
Goal2 = (LeftGoalTarget.CFrame(LeftGoalLocal:inverse())).p
LoopNo = LoopNo+1
local FirePos = (HumanoidRootPart.CFrameLeftFirePosition).p
local Progression = LoopNo/((Goal2-FirePos).magnitude/CastSpeed)
if Progression > 1 then Progression = 1 end
local Point = FirePos+(Goal2-FirePos)*Progression
LeftGrapple.Size = Vector3.new(1, 1, (FirePos-Point).magnitude)
LeftGrapple.CFrame = CFrame.new(FirePos+(Point-FirePos)/2, Goal2)
until (Point-Goal2).magnitude < 5 or not Keys[“q”]
Keys2[“q”] = true
if not Keys[“q”] then Keys2[“q”] = false return false end
return true
end
local Kd = game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(k)
if k == “e” then
if not game.Players.LocalPlayer:GetMouse().Target then
return
end
if (game.Players.LocalPlayer:GetMouse().Hit.p-HumanoidRootPart.Position).magnitude > 1000 then
RightGoal = Vector3.new()
return
end
if gasCount <= 0 then
return
end
local mouse = game.Players.LocalPlayer:GetMouse()
if mouse.Target.Parent.Name == “hitboxes” then
mouse.TargetFilter = mouse.Target.Parent
else
if cannotGrappleOn[mouse.Target.Name] then
print(“floor denied”)
if tick() - lastGroundGrapple < 5 then
mouse.TargetFilter = mouse.Target
return
else
lastGroundGrapple = tick()
end
end
end
if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) or mouse.Target.Parent.Parent ~= workspace and game.Players:GetPlayerFromCharacter(mouse.Target.Parent.Parent) then
mouse.TargetFilter = mouse.Target.Parent
return
end
if mouse.Target.Parent:findFirstChild(“DragonScript”) then
mouse.TargetFilter = mouse.Target.Parent
return
end
if not game.Players.LocalPlayer:GetMouse().Target then
mouse.TargetFilter = nil
return
end
Character.Humanoid.PlatformStand = true
DriftEnabled = true
Anim:Play()
a = Instance.new(“Sound”)
a.SoundId = “http://www.roblox.com/asset/?id=193202512”
a.Volume = 1
a.Pitch = 1
a.Parent = Character.HumanoidRootPart
a:play()
game.Debris:AddItem(a, 0.5)
Frl.CanCollide = true
Fll.CanCollide = true
RightGoal = CFrame.new(game.Players.LocalPlayer:GetMouse().Hit.p)
RightGoalLocal = RightGoal:inverse() * game.Players.LocalPlayer:GetMouse().Target.CFrame
RightGoalTarget = game.Players.LocalPlayer:GetMouse().Target
Keys.e = true
Velocity.maxForce = Vector3.new(Force, Force, Force)
Rotation.maxTorque = Vector3.new(Force, Force, Force)
mouse.TargetFilter = nil
local ret = CastRightGrapple(RightGoal, game.Players.LocalPlayer:GetMouse().Target)
if not ret then
return
end
else
do
if k == “q” then
if not game.Players.LocalPlayer:GetMouse().Target and not game.Players.LocalPlayer:GetMouse().Hit then
return
end
if (game.Players.LocalPlayer:GetMouse().Hit.p-HumanoidRootPart.Position).magnitude > 1000 then
LeftGoal = Vector3.new()
return
end
if gasCount <= 0 then
return
end
local mouse = game.Players.LocalPlayer:GetMouse()
if mouse.Target.Parent.Name == “hitboxes” then
mouse.TargetFilter = mouse.Target.Parent
else
if cannotGrappleOn[mouse.Target.Name] then
print(“floor denied”)
if tick() - lastGroundGrapple < 5 then
mouse.TargetFilter = mouse.Target
return
else
lastGroundGrapple = tick()
end
end
end
if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) or mouse.Target.Parent.Parent ~= workspace and game.Players:GetPlayerFromCharacter(mouse.Target.Parent.Parent) then
mouse.TargetFilter = mouse.Target.Parent
return
end
if mouse.Target.Parent:findFirstChild(“DragonScript”) then
mouse.TargetFilter = mouse.Target.Parent
return
end
if not game.Players.LocalPlayer:GetMouse().Target then
mouse.TargetFilter = nil
return
end
Character.Humanoid.PlatformStand = true
DriftEnabled = true
Anim:Play()
a = Instance.new(“Sound”)
a.SoundId = “http://www.roblox.com/asset/?id=193202512”
a.Volume = 1
a.Pitch = 1
a.Parent = Character.HumanoidRootPart
a:play()
game.Debris:AddItem(a, 0.5)
Frl.CanCollide = true
Fll.CanCollide = true
LeftGoal = CFrame.new(game.Players.LocalPlayer:GetMouse().Hit.p)
LeftGoalLocal = LeftGoal:inverse() * game.Players.LocalPlayer:GetMouse().Target.CFrame
LeftGoalTarget = game.Players.LocalPlayer:GetMouse().Target
Keys.q = true
Velocity.maxForce = Vector3.new(Force, Force, Force)
Rotation.maxTorque = Vector3.new(Force, Force, Force)
local ret = CastLeftGrapple(LeftGoal, game.Players.LocalPlayer:GetMouse().Target)
if not ret then
return
end
else
do
if k == " " and gasCount > 0 then
Character.Humanoid.WalkSpeed = 36
Gas = true
Character.Ejector.Gas.Enabled = true
else
if k == “d” and DriftEnabled == true then
DriftRight = true
RAnim:Play()
else
if k == “a” and DriftEnabled == true then
DriftLeft = true
LAnim:Play()
else
if k == “” and (Keys.q or Keys.e) then
Stalling = not Stalling
else
if k == “c” then
StallingDirectionUp = true
else
if k == “v” then
StallingDirectionDown = true
end
end
end
end
end
end
end
end
end
end
end)
local Ku = game.Players.LocalPlayer:GetMouse().KeyUp:connect(function(k)
local dorecoil = false
if (Keys.e and k == “e”) or Keys.q and k == “q” then
Anim:Stop()
dorecoil = true
blade = Character:GetChildren()
for i = 1, #blade do
if blade[i].Name == “Blade” and blade[i].Transparency ~= 0 then
Break = math.random(1, 2)
if Break == 1 then
B1:Play()
else
if Break == 2 then
B2:Play()
end
end
end
end
a = Instance.new(“Sound”)
a.SoundId = “http://www.roblox.com/asset/?id=193202522”
a.Volume = 1
a.Pitch = 1
a.Parent = Character.HumanoidRootPart
a:play()
game.Debris:AddItem(a, 0.5)
end
Keys[k] = nil
Keys2[k] = nil
if not Keys.q and not Keys.e and (k == “q” or k == “e”) then
DriftEnabled = false
local LastVelocity = HumanoidRootPart.Velocity
Velocity.maxForce = Vector3.new()
Rotation.maxTorque = Vector3.new()
Character.Humanoid.PlatformStand = false
Frl.CanCollide = false
Fll.CanCollide = false
Stalling = false
HumanoidRootPart.Velocity = LastVelocity
RightGoal = CFrame.new()
LeftGoal = CFrame.new()
end
do
if dorecoil then
JumpRecoil = workspace.DistributedGameTime
end
if not Keys.e then
RightGrapple.Transparency = 1
end
if not Keys.q then
LeftGrapple.Transparency = 1
end
if k == " " then
Character.Humanoid.WalkSpeed = 16
Gas = false
Character.Ejector.Gas.Enabled = false
end
if k == “c” then
StallingDirectionUp = false
end
if k == “v” then
StallingDirectionDown = false
end
end
end)
game:GetService(“UserInputService”).InputEnded:connect(function(Io)
if Io.KeyCode == Enum.KeyCode.D then
DriftRight = false
RAnim:Stop()
end
if Io.KeyCode == Enum.KeyCode.A then
DriftLeft = false
LAnim:Stop()
end
end)
local function UpdateVelocities()
if not Character then return end
if not HumanoidRootPart.Parent == Character then return end
local Goal = Vector3.new()
if not Keys[“q”] and Keys[“e”] then RightGoal = RightGoalTarget.CFrame*(RightGoalLocal:inverse()) Goal = RightGoal.p
elseif not Keys[“e”] and Keys[“q”] then LeftGoal = LeftGoalTarget.CFrame*(LeftGoalLocal:inverse()) Goal = LeftGoal.p
elseif Keys[“q”] and Keys[“e”] then RightGoal = RightGoalTarget.CFrame*(RightGoalLocal:inverse()) LeftGoal = LeftGoalTarget.CFrame*(LeftGoalLocal:inverse()) Goal = LeftGoal.p+(RightGoal.p-LeftGoal.p)/2
end
local Multiplier = 1
if Gas then
Multiplier = 2
a = Instance.new(“Sound”)
a.SoundId = “http://www.roblox.com/asset/?id=329934298”
a.Volume = 1
a.Pitch = 1
a.Parent = Character.HumanoidRootPart
a:play()
game.Debris:AddItem(a,0.5)
end
local OrbitVelocity = Vector3.new()
if DriftRight and not DriftLeft then
local MultiplierOrbit = Speed*.5Multiplier
if Keys[“q”] then MultiplierOrbit = Speed1.4 end
local Dir = (HumanoidRootPart.CFrameCFrame.Angles(0, -math.rad(45), 0)).lookVector
OrbitVelocity = DirMultiplierOrbit
elseif DriftLeft and not DriftRight then
local MultiplierOrbit = Speed*.5Multiplier
if Keys[“e”] then MultiplierOrbit = Speed1.4 end
local Dir = (HumanoidRootPart.CFrameCFrame.Angles(0, math.rad(45), 0)).lookVector
OrbitVelocity = DirMultiplierOrbit
end
if not Stalling then
StallingDistance = (HumanoidRootPart.Position-Goal).magnitude
Velocity.velocity = CFrame.new(HumanoidRootPart.Position, Goal).lookVectorSpeedMultiplier+OrbitVelocity
Rotation.cframe = CFrame.new(HumanoidRootPart.Position, Goal)
elseif Stalling then
StallingDistance = (HumanoidRootPart.Position-Goal).magnitude
local DownPos = Goal-Vector3.new(0,StallingDistance,0)
local DownArcVelocity = Vector3.new()
if (Torso.HumanoidRootPart-DownPos).magnitude > 3.5 then
DownArcVelocity = (HumanoidRootPart.CFrameCFrame.Angles(-math.rad(90),0,0)).lookVector50
end
local Maintain = Vector3.new(0,0,0)
if StallingDirectionDown and not StallingDirectionUp then
Maintain = Vector3.new(0,-10,0)
elseif StallingDirectionUp and not StallingDirectionDown then
Maintain = Vector3.new(0,10,0)
end
Velocity.velocity = DownArcVelocity+Maintain
Rotation.cframe = CFrame.new((HumanoidRootPart.CFrame*CFrame.new(0,5,0)).p, Goal)
end
end
local UpdateGrapples = function()
local RGposX, RGposY, RGposZ = RightGoal.X, RightGoal.Y, RightGoal.Z
local LGposX, LGposY, LGposZ = LeftGoal.X, LeftGoal.Y, LeftGoal.Z
–RGoalVal.Value = RightGoal.p
–LGoalVal.Value = LeftGoal.p
RGoalVal.Value = Vector3.new(RGposX, RGposY, RGposZ)
LGoalVal.Value = Vector3.new(LGposX, LGposY, LGposZ)
if Keys2[“e”] then
RGrappleBool.Value = true
RightGrapple.Transparency = 0
local FirePos = (HumanoidRootPart.CFrameRightFirePosition).p
RightGrapple.Size = Vector3.new(1, 1, (FirePos-RightGoal.p).magnitude)
RightGrapple.CFrame = CFrame.new(FirePos+(RightGoal.p-FirePos)/2, RightGoal.p)
else
RGrappleBool.Value = false
end
if Keys2[“q”] then
LGrappleBool.Value = true
LeftGrapple.Transparency = 0
local FirePos = (HumanoidRootPart.CFrameLeftFirePosition).p
LeftGrapple.Size = Vector3.new(1, 1, (FirePos-LeftGoal.p).magnitude)
LeftGrapple.CFrame = CFrame.new(FirePos+(LeftGoal.p-FirePos)/2, LeftGoal.p)
else
LGrappleBool.Value = false
do
LGrappleBool.Value = false
if Velocity.maxForce ~= Vector3.new() then
gasCount = gasCount - 1
end
if leftGrappleOn and rightGrappleOn then
gasCount = gasCount - 1
end
if Gas == true then
gasCount = gasCount - 2
end
if gasCount <= 0 then
gasCount = 0
DriftEnabled = false
local LastVelocity = HumanoidRootPart.Velocity
Velocity.maxForce = Vector3.new()
Rotation.maxTorque = Vector3.new()
Character.Humanoid.PlatformStand = false
Frl.CanCollide = false
Fll.CanCollide = false
Stalling = false
–[[if RightGoal.p ~= Vector3.new() or LeftGoal.p ~= Vector3.new() then
if JumpRecoil+RecoilTime < workspace.DistributedGameTime then
Character.Humanoid.Jump = true
end
end]]–
HumanoidRootPart.Velocity = LastVelocity
RightGoal = CFrame.new()
LeftGoal = CFrame.new()
LeftGrapple.Transparency = 1
RightGrapple.Transparency = 1
Gas = false
Character.Humanoid.WalkSpeed = 16
Character.Ejector.Gas.Enabled = false
end
do
updateGasDisplay()
end
end
end
end
game:GetService(“RunService”).RenderStepped:connect(UpdateGrapples)
game:GetService(“RunService”).Stepped:connect(UpdateVelocities)
wait(1)
B2:Stop()
B1:Stop()
MassUpdate()
wait(1)
Character.ChildAdded:connect(MassUpdate)
Character.ChildRemoved:connect(MassUpdate)
Character.Humanoid.Died:connect(function()
Kd:disconnect()
Ku:disconnect()
RightGrapple:remove()
LeftGrapple:remove()
end)
repeat
wait()
until game.Workspace:FindFirstChild(“RefreshBladesAndGasRE”)
game.Workspace.RefreshBladesAndGasRE.Touched:connect(function(args)
local difference = capGas - gasCount
local toFill = 0
if args then
toFill = math.clamp(args[2], 0, difference)
if args[2] < toFill then
toFill = args[2]
end
else
toFill = difference
end
gasCount = gasCount + toFill
updateGasDisplay()
if args then
game.Workspace.RefreshBladesAndGasRE:FireServer({args[1], toFill, 0})
end
end)
woah you might want to make a closable tab when putting that much code.
your gonna have to use remote events then like i suggested in my first reply
Yeah, it looks like you’re using a local script
Yeah if I turn this into a regular script, none of the functions will work.