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 3 years ago

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

local SwordFightingArea = game.Workspace
local ClassicSword = game.ServerStorage
local StarterPack = game.StarterPack
local Players = game.Players
local NotSwordFightingArea = game.workspace.NotSwordFightingArea
local ServerStorage = game.ServerStorage 

SwordFightingArea.Touched:Connect(function(player)
    ClassicSword:Clone()
    local ClassicSword = ClassicSword:FindFirstAncestor("StarterPack")
    print (player.name .. "has a sword")
    NotSwordFightingArea.Touched:Connect(function()
        StarterPack.ClassicSword:Delete()
    end)
end)

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
3 years ago
Edited 3 years ago

Correct script:

game.Players.PlayerAdded:Connect(function(player)
    local ClassicSwordClone = game.ServerStorage.ClassicSword:Clone()
    local NotSwordFightingArea = game.Workspace.NotSwordFightingArea

    ClassicSwordClone.Parent = player.Backpack
    print (player.Name .." has a sword")

    NotSwordFightingArea.Touched:Connect(function()
        StarterPack.ClassicSword:Destroy()
    end)
end)

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 — 3y
0
Yes, you can Xapelize 2658 — 3y
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 — 3y
Ad
Log in to vote
0
Answered by 3 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 — 3y

Answer this question