#It works fine in studio, but it doesnt work in Rblx

1 messages · Page 1 of 1 (latest)

pastel radish
#

So, this script makes it so when the player hovers their mouse over a model that has the "Highlighted Instances" tag, that model will be outlined but it only works in studio and not when i test it in rblx itself. pls help.

#

this is a local script inside starter player scripts

narrow matrix
#

try using a click detector and using clickDetector.MouseHoverEnter

#
local part = script.Parent
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part

clickDetector.MouseHoverEnter:Connect(function(player)
    print(player.Name .. " is hovering over the part")
    part.Color = Color3.fromRGB(0, 255, 0) -- turns green
end)

clickDetector.MouseHoverLeave:Connect(function(player)
    print(player.Name .. " stopped hovering")
    part.Color = Color3.fromRGB(255, 0, 0) -- turns red
end)
#

like this

#

just keep a highlight in replicated storage to clone it or something

#

or do highlight:Destroy() on .MouseHoverLeave with Instance.new()

hushed galleon
obtuse swift
#

u used ai didnt u?

#

@pastel radish

#

also, have you ever heard of "Module Scripts"?

fervent sigil
stuck marsh
fervent sigil
rugged ferry
#

you forgot to press publish

stuck marsh
#

since there will be other types u can filter out

fervent sigil
#

If he needs to add more things to the filter, he can just add more to the table

stuck marsh
# fervent sigil Wdym

instead of that why not module it to add its direct filter list so u dont have to worry about the one long table

fervent sigil
stuck marsh
# fervent sigil I think there's just something with how you're wording it that I'm not understan...

where u can keep track of all Filter types```lua

export type Filter = {
Add: (self: Filter, instances: {Instances}) -> (),
Remove: (self: Filter, instance: {Instance}) -> (),
}

local Filter = {}
Filter.__index = Filter

function Filter.new(filterType: 'Exclude'|'Include'): Filter
local self = {}
self.Params = RaycastParams.new()
self.Params.FilterType = filterType or Enum.RaycastFilterType.Exclude
self.Params.FilterDescendantsInstances = {}
return setmetatable(self, Filter)
end

function FIlter:Add(instances: {Instances})
for _, ins in ipairs(instances) do
table.insert(self.Params.FilterDescendantsInstances, ins)
end
end

function Filter:Remove(instances: {Instance})
local set = {}
for _, inst in ipairs(instances) do
set[inst] = true
end
local newList = {}
for _, inst in ipairs(self.Params.FilterDescendantsInstances) do
if not set[inst] then
table.insert(newList, inst)
end
end
self.Params.FilterDescendantsInstances = newList
end

function Filter:SetType(filterType: Enum.RaycastFilterType)
self.Params.FilterType = Filter
end

function Filter:GetParams(): RaycastParams
return self.Params
end

return Filter```

fervent sigil
stuck marsh
#

i know its kinda confusing at first

primal beaconBOT
#

studio** You are now Level 10! **studio

fervent sigil
#

For the person posting the problem, though, I still don't think it's necessary unless they're planning on doing a lot more with the filter than what is currently being shown

stuck marsh
#

yep thats just what i would use for what ill be doing for what ill have
but u would be able to add on to it and much more