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
We place the remote event anywhere in the game (has to be accessible by client AND server).
Access the remote from client and server, like this:
local remote = game.ServerStorage.RemoteEvent
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
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)
-- 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)
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.