You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
i want to make a very simple throwing system - What is the issue? Include screenshots / videos if possible!
the throwing’s physics only simulate when getting close
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local heldPart = nil
for i, part in ipairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and part:HasTag("X") then
local prompt = Instance.new("ProximityPrompt", part)
prompt.Triggered:Connect(function()
if heldPart then return end
prompt.Enabled = false
heldPart = part
local character = player.Character or player.CharacterAdded:Wait()
local weld = Instance.new("WeldConstraint", part)
weld.Part0 = character:WaitForChild("HoldPos")
weld.Part1 = part
end)
end
end
workspace.ChildAdded:Connect(function(part)
if part:IsA("BasePart") and part:HasTag("X") then
local prompt = Instance.new("ProximityPrompt", part)
prompt.Triggered:Connect(function()
if heldPart then return end
prompt.Enabled = false
heldPart = part
local character = player.Character or player.CharacterAdded:Wait()
part.CFrame = character:WaitForChild("HoldPos").CFrame
local weld = Instance.new("WeldConstraint", part)
weld.Part0 = character:WaitForChild("HoldPos")
weld.Part1 = part
end)
end
end)
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q and heldPart then
heldPart:WaitForChild("WeldConstraint"):Destroy()
local attachment = Instance.new("Attachment", heldPart)
heldPart.Anchored = false
heldPart:ApplyImpulse(player.Character.Head.CFrame.LookVector * 80)
heldPart:FindFirstChild("ProximityPrompt").Enabled = true
heldPart = nil
end
end)
its a local script located in starterplayerscripts