Whenever the player Jumps it should unweld the part and weld it after. Although, it certainly works I’m having an issue which it only affects a single player. I’ve tried to put the script onto the PlayerAdded event but to no avail.
Local script:
local player = game.Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local unweldPartFunction = RS:WaitForChild("UnweldPartFunc")
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Space then
unweldPartFunction:FireServer()
end
end)
Script:
local RS = game:GetService("ReplicatedStorage")
local unweldPartFunction = RS:WaitForChild("UnweldPartFunc")
game.Players.PlayerAdded:Connect(function(player)
local charac = player.CharacterAdded:Wait()
head = charac:WaitForChild("Head")
part = Instance.new("Part", game.Workspace.PartsOnHead)
part.Name = "partonhead"
part.CFrame = head.CFrame * CFrame.new(0,2,0) -- Sets the Position above the head
weld = Instance.new("WeldConstraint") -- welds the item and the head
weld.Part0 = head
weld.Part1 = part
weld.Parent = head
end)
unweldPartFunction.OnServerEvent:Connect(function(player)
part.Anchored = true
weld.Enabled = false
wait(2)
part.CFrame = head.CFrame * CFrame.new(0,2,0)
part.Anchored = false
weld.Enabled = true
end)