So im trying to make a tool that has a swinging effect using hinges when you move around, but when you equip it, unequip it, then re equip it, it glitches behind you and moves the character. The tool worked fine with a local script, but not using remote events or server scripts.
Things I tried:
-
making a weld constraint (connected from the “attachment 0” part of the hinge with the “attachment 1” part of the hinge) that gets disabled 0.25s after equipping the tool
(wich temporarly freezes the hinge so that it has time to catch up to the player.)
and when the tool is unequipped the weld gets enabled.
Here:
-
making it so the hinge gets created on equip after the weld gets disabled, and destroying the hinge after the tool is unequipped.
Attachments:
Scripts:
local SeeGlitchFixEvent = game.ReplicatedStorage:WaitForChild("SeeGlitchFixEvent")
local tool = script.Parent
local Handle1 = tool.Handle
local GlitchFix = Handle1.Fix
local function SeeGlitchFixFunction()
wait(0.25)
GlitchFix.Enabled = false
wait()
local HingeConstraint = Instance.new("HingeConstraint")
HingeConstraint.Parent = tool.Handle
HingeConstraint.Radius = 0.1
HingeConstraint.Visible = false
HingeConstraint.Enabled = true
HingeConstraint.Attachment0 = tool.Handle.Attachment1
HingeConstraint.Attachment1 = tool.Outside.Attachment01
HingeConstraint.LimitsEnabled = true
HingeConstraint.LowerAngle = -25
HingeConstraint.UpperAngle = 25
HingeConstraint.Restitution = 0
HingeConstraint.Name = "HingeFix"
end
SeeGlitchFixEvent.OnServerEvent:Connect(SeeGlitchFixFunction)
local StopSeeGlitchFixEvent = game.ReplicatedStorage:WaitForChild("StopSeeGlitchFixEvent")
local tool = script.Parent
local Handle1 = tool.Handle
local GlitchFix = Handle1.Fix
local function StopSeeGlitchFixFunction()
GlitchFix.Enabled = true
tool.Handle:WaitForChild("HingeFix"):Destroy()
end
StopSeeGlitchFixEvent.OnServerEvent:Connect(StopSeeGlitchFixFunction)
local SeeActivatedP1Event = game.ReplicatedStorage:WaitForChild("SeeActivatedP1Event")
local SeeActivatedP2Event = game.ReplicatedStorage:WaitForChild("SeeActivatedP2Event")
local SeeActivatedP3Event = game.ReplicatedStorage:WaitForChild("SeeActivatedP3Event")
local SeeGlitchFixEvent = game.ReplicatedStorage:WaitForChild("SeeGlitchFixEvent")
local StopSeeGlitchFixEvent = game.ReplicatedStorage:WaitForChild("StopSeeGlitchFixEvent")
tool = script.Parent
local Handle1 = tool.Handle
local CTRL = Handle1.CTRL
local anim = tool:WaitForChild("Animation")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local loadanim = humanoid:loadAnimation(anim)
tool.Activated:Connect(function()
if CTRL.Parent == tool.Handle then
SeeActivatedP1Event:FireServer()
loadanim:Play()
end
end)
tool.Activated:Connect(function()
if CTRL.Parent == tool.Face then
SeeActivatedP2Event:FireServer()
loadanim:Play()
end
end)
tool.Activated:Connect(function()
if CTRL.Parent == tool.Inside then
SeeActivatedP3Event:FireServer()
loadanim:Play()
end
end)
tool.Equipped:Connect(function(OnEquip)
SeeGlitchFixEvent:FireServer()
end)
tool.Unequipped:Connect(function(OnUnequip)
StopSeeGlitchFixEvent:FireServer()
end)
The other three scripts don’t affect anything that has to do with the hinges or the tool glitching behind.
Help/Explenations would be appreciated.