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

Help with making this place block script work correctly?

Asked by 7 years ago
Edited 7 years ago

I am trying to make this script place a block, but when I hit the correct button, nothing happens (Yes selected has a value, game.Lighting.1) Here is the script:

--LocalScript
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local Placing = false
local Already = false
function Place()
    local Xpos = Mouse.Target.Position.X
    local Ypos = Mouse.Target.Position.Y
    local Zpos = Mouse.Target.Position.Z
    local Surface = Mouse.TargetSurface
    local TargetPos = Mouse.Target.Position
    local Selected = game.Players.LocalPlayer.Selected.Value
    local Clone = Selected:Clone()
    Clone.Position = Vector3.new(TargetPos)
    if Surface == 1 then
        Clone.Position = Vector3.new(Xpos, Ypos + 4, Zpos)
    else
        if Surface == 4 then
            Clone.Position = Vector3.new(Xpos, Ypos - 4, Zpos)
        else
            if Surface == 3 then
                Clone.Position = Vector3.new(Xpos - 4, Ypos,  Zpos)
            else 
                if Surface == 0 then
                    Clone.Position = Vector3.new(Xpos + 4, Ypos, Zpos)
                else
                    if Surface == 2 then
                        Clone.Position = Vector3.new(Xpos, Ypos, ZPos + 4)
                        if Surface == 5 then
                            Clone.Position = Vector3.new(Xpos, Ypos, Zpos - 4)
                        else
                            print(" ")
                        end
                    end
                end
            end
        end
    end
end

Mouse.Button2Down:connect(function()
    local Find = Mouse.Target:FindFirstChild("Xplo")
    if not Already then
    Already = true
    Placing = true
    if Find then
    while true do
        wait(1)
        if Placing == true then
            Place()
        else
            print(" ")
        end
    end
    end
    end
    end)

Mouse.Button2Up:connect(function()
    Already = false
    Placing = false
end)
0
You have to clone on the server for it to replicate! Remember to use Remotes Goulstem 8144 — 7y
0
What? This does not have FilteringEnabled. TinyScripter 70 — 7y
0
I do not condone, nor suggest, non-FE game development. But also it seems like you never parented the clone. Goulstem 8144 — 7y
0
Oh. Thanks for that! I keep forgetting! TinyScripter 70 — 7y
View all comments (3 more)
0
Nevermind, still nothing happens. TinyScripter 70 — 7y
0
You put Clone.Parent = game.Workspace and nothing happens? (also a tip: you dont need to put else all those times. you can either make them all seperate if statements and remove all the elses which are currently serving no purpose, or you can combine them to "elseif" and only use one end) UnityAlex 36 — 7y
0
I tryed that and it still wont work TinyScripter 70 — 7y

Answer this question