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
3 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)

            local magnitude = (Player.Character.PrimaryPart.Position - script.Parent.Position).magnitude
            while magnitude < [1] do
                magnitude = (Player.Character.PrimaryPart.Position -Door.Hitbox.Position).magnitude
                wait(0.1)
            end
            Player.Character.[Heal]:Destroy()
        end
    end
end

end)

1 answer

Log in to vote
0
Answered by 3 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.

local block = game.Workspace.MF local sword = game.ReplicatedStorage.Heal
--edit the below values
local DistanceNumber = 10 --distance from center of part where it will delete the sword
local SwordName = "Heal" --name of the sword to be deleted

block.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChildWhichIsA("Tool") and  game.Players[hit.Parent.Name].Backpack:FindFirstChild(sword.Name) then
        local Character = hit.Parent
        sword:Clone().Parent = Character
        print(sword.Name .. " gave to " .. Character.Name)
        local magnitude = (Player.Character.PrimaryPart.Position - script.Parent.Position).magnitude
        while magnitude < DistanceNumber do
            magnitude = (Player.Character.PrimaryPart.Position -script.Parent.Position).magnitude
            wait(0.1)
        end
        Player.Character[SwordName]:Destroy()
        print(SwordName .. "removed from " .. Character.Name)
    end
end
Ad

Answer this question