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

I need help putting the script together correctly, please help?

Asked by
xoquez -11
4 years ago

I'm not sure how to put the final script together correctly i keep getting the following error:

Expected identifier when parsing expression, got '['

local block = game.Workspace.MF local sword = game.ReplicatedStorage.Heal

block.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if not hit.Parent:FindFirstChildWhichIsA("Tool") then if not game.Players[hit.Parent.Name].Backpack:FindFirstChild(sword.Name) then sword:Clone().Parent = hit.Parent print(sword.Name .. " gave to " .. hit.Parent.Name)

1            local magnitude = (Player.Character.PrimaryPart.Position - script.Parent.Position).magnitude
2            while magnitude < [1] do
3                magnitude = (Player.Character.PrimaryPart.Position -Door.Hitbox.Position).magnitude
4                wait(0.1)
5            end
6            Player.Character.[Heal]:Destroy()
7        end
8    end
9end

end)

1 answer

Log in to vote
0
Answered by 4 years ago

I noticed a couple flaws in my script, since I pasted out of another script I had. Sorry about that... This should work. Just edit the values at the top.

01local block = game.Workspace.MF local sword = game.ReplicatedStorage.Heal
02--edit the below values
03local DistanceNumber = 10 --distance from center of part where it will delete the sword
04local SwordName = "Heal" --name of the sword to be deleted
05 
06block.Touched:Connect(function(hit)
07    if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChildWhichIsA("Tool") and  game.Players[hit.Parent.Name].Backpack:FindFirstChild(sword.Name) then
08        local Character = hit.Parent
09        sword:Clone().Parent = Character
10        print(sword.Name .. " gave to " .. Character.Name)
11        local magnitude = (Player.Character.PrimaryPart.Position - script.Parent.Position).magnitude
12        while magnitude < DistanceNumber do
13            magnitude = (Player.Character.PrimaryPart.Position -script.Parent.Position).magnitude
14            wait(0.1)
15        end
16        Player.Character[SwordName]:Destroy()
17        print(SwordName .. "removed from " .. Character.Name)
18    end
19end
Ad

Answer this question