Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

5 comments

0

Yes...I forgot to put in the .position. Thanks TheBigBro122

0

Alrighty, no problem... You could make the post as a solution if you want, I'll really appreciate it

0

How do I close my response... It’s my first time using this

0

Or I mean how do I make your solution, a solution?

0

Oh I got it...

This discussion is preserved as it was. New answers, comments, and votes are closed.