Clone A Part onto a Players Root Position from gui button

Hello, im after a way to press a button and clone a part onto a humanoid root part and then after 3 seconds it disappears + bonus: Be immune to Explosions.
Code so far:

local player = script:FindFirstAncestorOfClass("Player")

script.Parent.MouseButton1Click:Connect(function(click)
	local post = player.Character.HumanoidRootPart.Position
	game.ReplicatedStorage.AbilityClones.Diamond:Clone().Position = post
end)

p.s: nothing happens and no errors for this code ^
(server script through screen gui in button)
any ideas/ solutions. I thank you for reading this post

2 Likes

Make this a localscript and use remote events

the only issue is im not good with remote events.like idk how to get a server to talk to the client and in reverse aswell

Then learn it. Don’t create a forum post without even searching on the internet

ive tried remote events before, its just too tricky for me

They’re actually very simple.

  1. We place the remote event anywhere in the game (has to be accessible by client AND server).

  2. Access the remote from client and server, like this:

    local remote = game.ServerStorage.RemoteEvent
    
  3. To fire the remote from client and server (send a message) we do:
    Client

    remote.FireServer('from client') -- any arguments you want
    

    Server

    local player = game.Players.ItzBloxyDev
    remote.FireClient(player,'from server') -- any arguments you want must include the player as first argument
    
  4. To recieve the remote from client and server we do:
    Client

    remote.OnClientEvent:connect(function(msg) -- any variables that were sent
       print(msg)
    end)
    

    Server

    remote.OnServerEvent:connect(function(player,msg) -- any variables that were sent (player always first)
       print(player..' sent remote with message: '..msg)
    end)
    

ill keep note of this thanks! :)))

1 Like

Use a local script and fire a remote event.

-- Local script
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") -- You have to create remote event

local food -- your thing

local yes = script.Parent

yes.Activated:Connect(function()
remote:FireServer(food)
end)

And… this is server script.

local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") -- You have to create remote event

remote.OnServerEvent:Connect(function(Plr, food)
-- cloning process
end)

I already did this in other topic.

what do I do for local food? I am lost with that

local StuffName = game.ReplicatedStorage.AbilityClones:WaitForChild("Diamond")

P.S You don’t need a WTC for static content in replicatedstorage!
Also for OP just weld the part onto character HRP and it’ll work, make sure it’s unanchored and has no collisions.

Nothing happens be cause you didn’t set the parent of the clone part change it to this

local part = game.ReplicatedStorage.AbilityClones.Diamond:Clone().
part.Position = post