I wanna clone part from ReplicatedStorage to Workspace now the code that i have already works But i want the value like
Local player for example BolfstarPrimraryW
And i want the code on click you can add and remove the clone
local Glass = game.ReplicatedStorage.Glass local playerservice = game:GetService("Players") local player = workspace script.Parent.MouseButton1Click:connect(function() Glass:Clone().Parent = game.Players.LocalPlayer game.Workspace.Glass.Name = player.name end)
Just come up with some code: Not sure if it will work online but it works in the studio.
local Glass = game.ReplicatedStorage.Glass:Clone() -- Clone the glass when this script loads local playerservice = game:GetService("Players") local player = playerservice.LocalPlayer local Glass_Active = false -- Toggle for show/hiding the Glass local UserGlass = nil -- User Glass, This is set below! script.Parent.MouseButton1Click:connect(function() if(Glass_Active == false) then -- If the user has no glass create one! Glass_Active = true if(UserGlass == nil) then UserGlass = Glass:Clone() UserGlass.Parent = workspace end UserGlass.Name = player.Name else -- the user already has a Glass then lets put it away! Glass_Active = false if(UserGlass ~= nil) then -- Check to see if our UserGlass isn't allready equal nil UserGlass:Destroy() UserGlass = nil end end end)
local Glass = game.ReplicatedStorage.Glass local playerservice = game:GetService("Players") local player = playerservice.LocalPlayer script.Parent.MouseButton1Click:connect(function() Glass:Clone().Parent = workspace game.Workspace.Glass.Name = player.Name end)
Wrong code sorry!