Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ClickDetector, makes removes transparency not working? No error!?

The basic script, that when the NPC is Clicked I would like an outline I have unioned together around the NPC to appear; specifically I'd love a more fleshed out system so I can animate the NPC to wave and the box will stick to his hand... But I am not that advanced so this would do, but I can't seem to get it to work and it isn't giving an error at all?

I have no clue how to use DataStore, so using ServerScript service and adding all NPC's to a folder would be amazing It was supposed to be a E, to interact to talk; but select the npc with a click detector which would load the visibility force an animation (the player walking up to the npc) and then proceed to give options to talk to said npc whilst he runs through animations or whatever...

Thank you so much for your efforts in advanced, if anyone would like to join a group project with me and learn together I am down for that! Take care and thanks in advanced!

local npc = script.Parent.Parent
local SelectedVal = Instance.new("BoolValue")
SelectedVal.Name = "SelectedVal"
SelectedVal.Parent = npc.Selected
Selected = npc.Selected:GetDescendants()
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = npc.HighlightScript

if SelectedVal == true then 
	Selected.Transparency = 0
elseif SelectedVal == false then
	Selected.Transparency = 1

local function OnClick(player)

if ClickDetector.MouseHoverEnter == true then
	Selected.OutlineFloor.Transparency = 0
elseif ClickDetector.MouseClick == true then
	Selected.OutlineBody = 1 
end


script.Parent.ClickDetector.MouseClick:connect(OnClick)

end
end

1 comment

0

On line 16 and 18 you're checking if events equal true. Thats not how you do it. Make a boolean variable, and swap it whenever the clickdetector is clicked instead.

1 answer

:Connect is deprecated. Your first if statement isn't closed properly. You're attemptiing to tie your function to an event, inside of the function, that's an illogical syntaxing problem. It'll cause the Script to get confused. You're experiencing the life of a silent output, Eg. Debugging; it's not fun

local npc = script.Parent.Parent
local SelectedVal = Instance.new("BoolValue")
SelectedVal.Name = "SelectedVal"
SelectedVal.Parent = npc.Selected
Selected = npc.Selected:GetDescendants()
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = npc.HighlightScript
 
if SelectedVal == true then
    Selected.Transparency = 0
elseif SelectedVal == false then
    Selected.Transparency = 1
end

local function OnClick(player)
	if ClickDetector.MouseHoverEnter == true then
	    Selected.OutlineFloor.Transparency = 0
	elseif ClickDetector.MouseClick == true then
	    Selected.OutlineBody = 1
	end
end

script.Parent.ClickDetector.MouseClick:Connect(OnClick)

2 comments

0

-1, you didn't help the OP with the actual issue, but rather added some spaces to his code and changed one letter.

0

Okay, but I tried, wbu

This discussion is preserved as it was. New answers, comments, and votes are closed.