Hello, so basically im trying to create an advanced mining system for my game. Anyway when i have a script that auto equips the tool from a proximity prompt the tool is not visible unless the player manually unequips and reequips.
Is your tool mesh/part called “Handle” ?
Yeah, as soon as i manually put it into the character it equips as normal. After a bit of testing i believe its because its coming from replicated storage and im not specifying the location it has to be in during the script.
Are you using Humanoid:EquipTool() or just parenting the tool?
The tool will alter between the backpack folder in the player instance (Players > Player > Backpack) and the Player character.
Are you changing the parent at any time of the Handle or tool manually?
No i am not. This is the script im using.
local RemoteEvent = game.ReplicatedStorage:WaitForChild(“StartMining”)
local plr = game:GetService(“Players”).LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
RemoteEvent.OnClientEvent:Connect(function()
script.Parent.Enabled = true
local item = game.ReplicatedStorage:WaitForChild(“Pickaxe”):Clone()
item.Parent = char
end)
Try using Humanoid:EquipTool()
Something like this might work:
local RemoteEvent = game.ReplicatedStorage:WaitForChild(“StartMining”)
local plr = game:GetService(“Players”).LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
RemoteEvent.OnClientEvent:Connect(function()
script.Parent.Enabled = true
local item = game.ReplicatedStorage:WaitForChild(“Pickaxe”):Clone()
hum:EquipTool(item)
end)
Yeah, i just done that now with my own code to try what you previously said. Same issue is occurring.
Strange.
When the tool is equipped through the script, where is the tool located in workspace? Is the tool unattached from your hand and is falling into the void or is it actually connected to your hand but is invisible?
Maybe try setting the tool’s parent to workspace first.
I just made this quick script in studio and something like this would seem to work.
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
task.wait(1)
local Tool = script:WaitForChild("Tool"):Clone()
Tool.Parent = workspace
Humanoid:EquipTool(Tool)
end)
end)
Edit:
I just tried this without Humanoid:EquipTool() and just set the parent to the character directly and it seems to have worked the same as the script above. The problem might be caused by something else outside of the script, but I can’t be 100% sure.
I think im getting somewhere. After running a server i just noticed that other players dont see the tool although on my end i see the tool after un equiping and re equiping. Maybe it could be because the item is not being cloned through the server?
Wait, is the script a local script or a server script? It’ll only replicate to everyone if done on the server (server script).
Script highlighted in image is the script im using to manage it.
Im such an idiot, i think i have realized my problem
Oh okay, the problem is that.
An easy solution to this is just to use RemoteEvents to tell the server to create the tool.
You could also just weld the pickaxe model to the player’s hand if you don’t care about other people seeing the tools.
I am currently using a remoteEvent to determine when the prompt has been pressed.
Oh I just read the “OnClientEvent” part of your script. Woops, my bad. Ignore what I just said.
Well that’s not the problem then (the local script).
You said you realized the problem. I’m curious what it was.
I’m still trying to find a solution however i believe because the server wasnt cloning the tool instead the client was there as a bit of conflict between rendering the model in. (My theory at the moment) This is due to the script being ran through StarterGui and not ServerScriptService.
Oh wait no the local script was the problem. I just got confused. “Woops, my bad. Ignore what I just said.”
When the client presses E near the rock, it should fire a remote event to the server to create the tool.
The client should not create the tool after the “OnClientEvent” event. The server should create it after an “OnServerEvent.”
Yeah, thats what im attempting now.
And no worries i have made lots of errors tonight. Really tired lol
Just had problem and fixed it
local Tool = script:WaitForChild("Tool"):Clone()
but the next step is to parent it to backpack and possibly starterpack
so your tool will not be there in it’s original stored location …it will be in the backpack
after doing the >>in server script service script that is triggerd by server event from local script…
local newTool = tool:Clone()
newTool.Parent = Player.Backpack
local newTool = tool:Clone()
newTool.Parent = Player.StarterGear
and should be >>in local script
local tool = Player.Backpack.Tool
character.Humanoid:EquipTool(tool)
tools should be in server storage read up on why it’s most secure
your tool should be parented to backpack by script in serverscriptservice that is a remote event triggered by local script