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

Help with a code making it so if a player hovers your mouse over the brick, something pops up...?

Asked by 4 years ago

I am trying to make a code so that when the player’s mouse hovers over a block, another block appears on top of the block. I have put a script into the part. Here is my code:

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseHoverEnter:Connect(function()
game.Workspace.PlantExample.Position = script.Parent
end)

ClickDetector.MouseHoverLeave:Connect(function()
game.Workspace.PlantExample.Position = game.Workspace.PlantExampleStay
end)

I have put this code in a script(Not local) in Workspace. Workspace has filtering enabled, disabled.

Here is what my game looks like in the explorer tab:

\/ Workspace

    Baseplate
    \/ Placing1
       ClickDetector
       Script (Where my code above is)
       Part
    PlantExample
    PlantExampleStay

1 answer

Log in to vote
0
Answered by 4 years ago

You're just getting the part, not the part's position itself...

Change it to this

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseHoverEnter:Connect(function()
game.Workspace.PlantExample.Position = script.Parent.Position
end)

ClickDetector.MouseHoverLeave:Connect(function()
game.Workspace.PlantExample.Position = game.Workspace.PlantExampleStay.Position
end)

also PlantExample will go directly inside the script's Parent... so I recommend you offsetting it so it would go directly on top of the object.

game.Workspace.PlantExample.Position = script.Parent.Position + Vector3.new(0 ,5, 0) --Change 5 to your liking, the other values are irrelevant
0
Yes...I forgot to put in the .position. Thanks TheBigBro122 op_roblox2009 11 — 4y
0
Alrighty, no problem... You could make the post as a solution if you want, I'll really appreciate it TheBigBro122 427 — 4y
0
How do I close my response... It’s my first time using this op_roblox2009 11 — 4y
0
Or I mean how do I make your solution, a solution? op_roblox2009 11 — 4y
0
Oh I got it... op_roblox2009 11 — 4y
Ad

Answer this question