I need help with a script the will select an object in an inventory, then click the place button
The Local Script
local equipped = script.Parent.Parent.Parent.Inventory.Equipped
local selected = script.Parent.Parent.Parent.Inventory.Selected
local location = script.Parent.Parent.Parent.Inventory.Location
local player = game.Players.LocalPlayer
local character = player.Character
local Mouse = player:GetMouse()
script.Parent.MouseButton1Click:Connect(function()
equipped.Value = selected.Value
if equipped.Value == nil or equipped.Value ~= selected.Value then
print("Nothing Happened.")
else
local Model = selected.Value
Model.Parent = workspace
local GridSize = 1
function Snap()
PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
PosY = Model.PrimaryPart.Position.Y
PosZ = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize
end
function Movement()
Mouse.TargetFilter = Model
Snap()
Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
end
end
end)
Mouse.Move:Connect(Movement)