Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Clone part from ReplicatedStorage to Workspace?

Asked by 4 years ago

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)
0
you should put the Glass:Clone().Parent = game.Players.LocalPlayer.Character naturedat 124 — 4y

2 answers

Log in to vote
0
Answered by
TGazza 1336 Moderation Voter
4 years ago

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)
0
Thank you! The script works in studio not tested yet in online but now i'm working on a class system so that if a player select for example (Mp5) That gun will be selected for Primrary gun and the attachments will be loaded if the player press deploy but for dis system i use dis script so that the local player can view the gun and change the attachements/color bolfstar 2 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
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!

0
hmm what kinda like a toggle? aka Click once it clones then click again it removes?, Ill see what i can come up with TGazza 1336 — 4y

Answer this question