This is a hover brick script which make the "Decal" show up when someone hover their mouse over to the brick. But there's one problem though, whenever I move my character position, the hover brick doesn't work when I hover my mouse over the brick. Any ideas why this is happening?
Also, here is my layout: https://gyazo.com/4b634bcdc1a17d447ff033ba4005fca6
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local distance = 20 -- Set to whatever you want the distance to be
function onHover(plr)
local char = plr.Character
if char then
local torsoDistance = char.Torso.Position.magnitude
if torsoDistance < distance then
print(char.Torso.Position.magnitude)
return true
end
end
return false
end
while wait() do
if Mouse.Target ~= nil and Mouse.Target.Name == 'HoverBrick' then
local isCloseEnough = onHover(Player)
if isCloseEnough then
script.Parent.Frame.ImageLabel.Image = Mouse.Target.NewTexture.Texture
script.Parent.Frame.Visible = true
else
script.Parent.Frame.Visible = false
end
else
script.Parent.Frame.Visible = false
end
end
Thank you for your time and consideration.

1 comment
I'm assuming this is a local script, which it should be, and I'm assuming this is in a part in the workspace. Local scripts don't work in workspace.