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

How to move things from ServerStorage to StarterPack?

Asked by 4 years ago

It's weird because there were no errors in the output.

01local SwordFightingArea = game.Workspace
02local ClassicSword = game.ServerStorage
03local StarterPack = game.StarterPack
04local Players = game.Players
05local NotSwordFightingArea = game.workspace.NotSwordFightingArea
06local ServerStorage = game.ServerStorage
07 
08SwordFightingArea.Touched:Connect(function(player)
09    ClassicSword:Clone()
10    local ClassicSword = ClassicSword:FindFirstAncestor("StarterPack")
11    print (player.name .. "has a sword")
12    NotSwordFightingArea.Touched:Connect(function()
13        StarterPack.ClassicSword:Delete()
14    end)
15end)

I'd appreciate if someone could point out my error/s.

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Correct script:

01game.Players.PlayerAdded:Connect(function(player)
02    local ClassicSwordClone = game.ServerStorage.ClassicSword:Clone()
03    local NotSwordFightingArea = game.Workspace.NotSwordFightingArea
04 
05    ClassicSwordClone.Parent = player.Backpack
06    print (player.Name .." has a sword")
07 
08    NotSwordFightingArea.Touched:Connect(function()
09        StarterPack.ClassicSword:Destroy()
10    end)
11end)

YOU HAVE A VERY BAD PRACTICE: HERES THE ERRORS AND MISTAKES YOU DID

Line 1: Workspace is a service. Okay? Why would you do that, there's a built-in "shortcut" for you called workspace.

Line 2: ServerStorage is a service, not a sword!!!!!!!!!!

Line 3: Instead of locating StarterPack, cloning something into player's backpack you need to use player.Backpack. StarterPack clones it's children inside player's backpack. Don't write BackPack in your code! It's Backpack.

Line 4: Ok this is not like a mistake but you didn't even use it, why

Line 5: It is not game.workspace. You misspelled "Workspace" in the wrong capitalization. ALSO YOU LOCATED WORKSPACE BEFORE MEN WHY

Line 6: Same as line 4

Line 8: You can't touch workspace, its a service, consider changing to game.Players.PlayerAdded:Connect(function(player) if YOU want to detect someone joined. but more easier, you can put the sword in StarterPack.

Line 9: How are you suppose to clone a service

Line 10: You already named a variable called "ClassicSword" man

Line 11: Why would you do unnecessary spaces, do it as print(player.Name .." has a sword!" Also, capitalizate the "Name" correctly okay? Lastly, space before writting your sentence or it looks like this: Someonehas a sword!

Line 12: No errors, but your variable does

Line 13: There is no functions called :Delete, use :Destroy

Line 14/15: No errors

0
Thanks for the reply, I'll certainly have to rethink my approach. However I'm a little confused. In line 9 of the solution code you call the destroy function on the "Classic Sword", that's also in the starter pack. Should I call the function instead on the one that is cloned and that was put in the player's backpack at line 5? nafey200 59 — 4y
0
Yes, you can Xapelize 2658 — 4y
0
Assigning 2 function, one of them is giving sword, one of them is destroying sword, will can be repeatedly used instead of once Xapelize 2658 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

instad of starterpack try doing:

game.ServerStorage.ClassicSword:Clone().Parent = game.Players.LocalPlayer.BackPack

and in the string (..) do:

print (player.name.." has a sword")

instead of:

print (player.name .. "has a sword")

i don't thing that's all the mistakes but that's 2 of them

0
Look at my answer for all the errors by the way, you pointed some that I didn't notice Xapelize 2658 — 4y

Answer this question