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

I want to make so if you enter the mouse on a block a gui will opens?

Asked by 6 years ago

Hello,

I want to make so if the mouse target a brick a gui will be visible but its not working

This is the script i using now;

local player = game.Players.Localplayer
Mouse = player:GetMouse()

if Mouse.Target == "Part" then
player.PlayerGui.ScreenGui.Frame.Visible = true
end

1 answer

Log in to vote
0
Answered by
ax_gold 360 Moderation Voter
6 years ago

That is wrong in a couple ways.

  1. Mouse.Target is an object, so you should be looking for workspace.Part instead of "Part"

  2. Your script will only update once, and that's when the script first loads. You want to add in a part where the script will constantly update whenever the mouse is moved. Like so:

local player = game.Players.Localplayer
Mouse = player:GetMouse()

Mouse.Move:Connect(function()
    if Mouse.Target == workspace.Part then
        player.PlayerGui.ScreenGui.Frame.Visible = true
    end
end)
Ad

Answer this question