so im making a survival game, and if u kill an animal they drop meat, but if u hover over the meat, the highlight is supposed to enable (client), and when clicked, it would fire a remote, but it only enables server side, is there another method for client or is it only for server:
local clickDetector = script.Parent
clickDetector.MouseClick:Connect(function()
local item = "Raw Meat"
game.ReplicatedStorage.PickUpItem:FireServer(item)
print("why doesnt it work")
end)
clickDetector.MouseHoverEnter:Connect(function()
script.Parent.Parent.Highlight.Enabled = true
end)
clickDetector.MouseHoverLeave:Connect(function()
script.Parent.Parent.Highlight.Enabled = false
end)
Just use Mouse.Target in a loop and check if the target contains an “item” tag or something.
(Make sure to check the magnitude as well so the player can’t pick stuff up from across the map)
so something like this? ( i will do magnitude just an example )
while true do
task.wait()
if Mouse.Target == script.Parent.Parent then
script.Parent.Parent.Highlight.Enabled = true
else
script.Parent.Parent.Highlight.Enabled = false
end
end
where’s the Materials folder located? the local script cannot work within workspace, you have to move it into StartPlayerScripts and detect it from there
something like this? cuz i get an error of attempt to index nil with findfirstchildofclass:
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
while true do
task.wait()
if game:GetService("CollectionService"):HasTag(Mouse.Target, "Item") then
Mouse.Target:FindFirstChildOfClass("Highlight").Enabled = true
else
Mouse.Target:FindFirstChildOfClass("Highlight").Enabled = false
end
end
your code is not the problem ig
make sure that its a NORMAL script with runcontext set to client and not a client scripts
because client scripts donot work in workspace by default
add this script / the white script
and set run context to client