This is a hover brick that will show an image GUI whenever someone hover their mouse over the brick. But for some reason it doesn't work. If I move my character to a different position and hover the mouse over the brick, the image GUI isn't showing up. How come? Any ideas why this is happening?
Here's an image of my layout, please check them:
https://gyazo.com/b9a9ead14dfd6a69d534bc5a0845022f
Here's the image of the script (This is a regular script):
https://gyazo.com/9129737b7eb3de37e02fee10d255e511
game.Players.PlayerAdded:connect(function(newPlayer)
local plr = game.Players:FindFirstChild(newPlayer.Name)
if plr then
local gui = script:WaitForChild("ScreenGui"):Clone() -- if you change the name of "ScreenGui" change it in this script too.
gui.Parent = plr.PlayerGui
end
end)
Here's another script (This is a local script):
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
If you need to examine the mode, then click this link and it will take you straight to the model that I need help on:
https://www.roblox.com/Broken-item?id=462522261
Many thanks, my friend!
