Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the bullet clone?

I do not know why the Bullet doesn't clone please help

Player = game.Players.LocalPlayer Mouse = Player:GetMouse();

script.Parent.Activated:connect(function() game.ServerStorage.Bullet:Clone() game.ServerStorage.Bullet.Parent = workspace game.Workspace.Bullet.CFrame = Mouse.hit end)

3 comments

0

Please format your code and put it into a code block.

0

you should define them as variables, like local bullet = game.ServerStorage.Bullet:Clone(). Then set the Parent and CFrame using bullet.

0

can you format it into a code block or put each line of code on a seperate line

1 answer

Well I'm taking an educated guess and saying this is a LocalScript because you are getting the LocalPlayer from players. If so you cannot access ServerStorage from a LocalScript. Because of this you'll need to use both a LocalScript and a Script to get this done. First Create a LocalScript, a Script, and a RemoteEvent, ideally in the same Parent so we can get to it easily.

Let's start on the LocalScript, first we create an activated event, guessing that parent is a tool. When this event fires we will fire the remoteevent and send over the mouse hit

local mouse = game.Players.LocalPlayer:GetMouse()
local re = script.Parent.RemoteEvent

script.Parent.Activated:connect(function()
	re:FireServer(mouse.Hit)
end)

Now inside the Script we will create the event for the remoteevent and then clone the bullet

local re = script.Parent.RemoteEvent

re.OnServerEvent:connect(function(plr,hit)
	local bullet = game.ServerStorage.Bullet:Clone()
	bullet.Parent=workspace
	bullet.CFrame=hit
end)

Now in your script you had a few problems, but two of them were that you were not assigning the bullet's clone to a variable and that you were setting the bullet instance inside serverstorage aka the original instance's parent instead of the clone, also the same with the cframe Also you don't do mouse.hit, it's mouse.Hit, ;p

This discussion is preserved as it was. New answers, comments, and votes are closed.