How Would I Destroy Local Parts?

no I mean if the player has already touched it, when they join back again it does not show up

Then you need to add a DataStore to your game which saves a boolvalue of localplayer once they leave the game. Let’s say that default value is false and once they touch the part it should turn to true and once player leaves the game this value should save in a DataStore. You will need more scripts to make this work in your game. There are many tutorials online of course, I’d recommend you a DataStore2 but if you are a beginner then try to make it work with a normal DataStore. So once player will join a game again it won’t duplicate a part in game because it will have a boolvalue set to true. I hope this helps. :herb:

Figured I’d drop by since no one updated you on this yet, you misunderstood what he meant, you don’t necessarily need to recreate the model part by part from a script to make a local part, a local part is just a part/model that is parented to the workspace or it’s descendant via a localscript / a module that is required from a localscript.

You can make the model and put it in ReplicatedStorage and then clone that model in a localscript, parent it to workspace and use SetPrimaryPartCFrame to move the model where you want it to be. After that, simply bind a touched event to a hitbox of your choice in that model and destroy it upon doing so and fire a remote to the server to inform the server that so and so occured.

Example code,

local remote = -- the remoteevent you use to tell the server the player picked up the candy
local position = -- where you want the candy to be positioned at
local cl = game.ReplicatedStorage.CandyModel:Clone()
cl.Parent = workspace
cl:SetPrimaryPartCFrame(CFrame.new(position))

cl.PrimaryPart.Touched:Connect(function()
   cl:Destroy()
   remote:FireServer()
end)

Just a note however, to those who may question the security on this systems, OP requested the method in doing so, security is an entirely different topic especially when the game system requires to be on the client for a more responsive gameplay :+1:

1 Like