If you know from SFOTH, you have those power-ups in the game that are stuck on a part/stand and they don’t move (even if you use a rocket launcher on them for example), and you’re able to equip the tool normally, and use it (and it regens in the same spot after some time too).
Now I have the regen scripts and everything ready, but for some reason, the tools don’t stand still/stay stuck, they always fall off the stand, and if you use weapons on it (rocket launcher for example), they would fly away and get flung. How can I keep them stuck on a part/stand like in SFOTH?
Picture for reference:
2 Likes
Have you tried anchoring the tool and then unachoring the player’s clone of the tool when they pick it up?
2 Likes
Can you elaborate, please? Because the tool is taken once a player touches it and is no longer there but it regens after a specific time in that same spot
How does your system work? Do you clone the tool, give the clone to the player, and then hide the original until the regen cooldown is over?
If so, then you should just be able to anchor the primary part of the original and then unanchor the clone of the tool whenever it’s made.
3 Likes
What you could do is store the tools in a folder in ReplicatedStorage or ServerStorage and just have the handle itself anchored and spawn / regen in that location. From there, when you capture that the handle has been touched, set the handle’s parent to nil and clone the tool to place in the player’s backpack or character.
If you go with this method, name the handles the same name as the tool stored in the folder so you could do something like this:
local debounce = false
handle.Touched:Connect(function(hit)
if not debounce then
debounce = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local tool = Folder:findFirstChild(handle.Name)
if tool then
tool:Clone().Parent = plr.Backpack
handle.Parent = nil
end
end
debounce = false
end
end)
Let me know if you need further assistance.
1 Like
I’ll use the Medkit tool as an example:
How it looks like in Workspace (Cylinder MeshParts are just the base/stand of the tool):
The Regen script:
bin = script.Parent
ItemName = "MedKit" -- The name of the item in the stand.
WaitTime = 120 -- The amount of time to wait before regenerating the item.
Item = bin:findFirstChild(ItemName)
backup = Item:clone()
function regen()
local regen = backup:clone()
regen.Parent = bin
end
debounce = false
function onTaken(property)
if (debounce == true) then return end
debounce = true
if (bin:findFirstChild(ItemName) == nil) then
wait(WaitTime)
regen()
end
debounce = false
end
Item.Changed:connect(onTaken)
The properties of the MedKit gear:
Try setting the Anchored
property of the medkit’s handle part to true
, and when the medkit is taken, set the Anchored
property of the medkit that was taken to false
so that the player can carry it properly.
By doing this, the part would not be able to move around until it has been picked up by the player.