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

How do I summon a model from serverstorage at a position relative to the ClickDetector?

Asked by 8 years ago
Edited 8 years ago
local storage = game:GetService("ServerStorage")

function OnClick(Clicker)  
    if Clicker.leaderstats.Tacks.Value > 2 then
        print("Greater than two!")
        if Clicker.TeamColor.Name == "Bright Green" then
            print("Go Green for Green Team!")
            for i,v in pairs(game.Workspace:GetChildren()) do
                if v.Name == "ClickableBlock" then
                        Clicker.leaderstats.Tacks.Value = Clicker.leaderstats.Tacks.Value - 2
                        v.ClickDetector.MouseClick:connect(function(Clicker)
                        local part = storage["squareGreen2"]:clone()
                        part.Parent = game.Workspace
                        part:MoveTo (Vector3.new(2.25, 686.658, 665.099))
                end)
            end
        end
    end
    else
        print("nope")
    end
end
script.Parent.MouseClick:connect(OnClick)  

I want to have a bunch of blocks with clickdetectors that checks if you have enough "Tacks" and if you do, summons a model "squareGreen2" directly above the click block. Is there a way to summon at a relative position to the block the click detectors in?

Also, the first time the block is pressed, the "tacks" value is decreased by two and Print("Payed for Square" is printed, but the model isnt summoned. The second press and afterwards it is though

Answer this question