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

Click detector local event not running?

Asked by 4 years ago

I am trying to make it some when you hover over a part it's bilboard gui highlight (by setting text stroke transparency = 0). But when I did

local ts = game:GetService("TweenService")

local linear_bi = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

script.Parent.MouseHoverEnter:Connect(function(plr)
    local tween = ts:Create(script.Parent.Parent.BeforeHead.TextLabel, linear_bi, {
        TextStrokeTransparency = 0
    })
    tween:Play()
end)

script.Parent.MouseHoverLeave:Connect(function(plr)
    local tween = ts:Create(script.Parent.Parent.BeforeHead.TextLabel, linear_bi, {
        TextStrokeTransparency = 1
    })
    tween:Play()
end)

Then I looked for other questions on here and got the idea of using RemoteEvent on the server and firing the client. However when I did this it didn't work. SERVER

script.Parent.MouseClick:Connect(function()
    script.Parent.Parent.Parent.Health.Value = script.Parent.Parent.Parent.Health.Value - 1
end)

script.Parent.MouseHoverEnter:Connect(function(plr)
    script.Parent.Enter:FireClient(plr)
end)

script.Parent.MouseHoverLeave:Connect(function(plr)
    script.Parent.Leave:FireClient(plr)
end)

CLIENT

local ts = game:GetService("TweenService")

local linear_bi = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

script.Parent.Enter.OnClientEvent:Connect(function(plr)
    print("Enter CLIENT")
    local tween = ts:Create(script.Parent.Parent.BeforeHead.TextLabel, linear_bi, {
        TextStrokeTransparency = 0
    })
    tween:Play()
end)

script.Parent.Leave.OnClientEvent:Connect(function(plr)
    local tween = ts:Create(script.Parent.Parent.BeforeHead.TextLabel, linear_bi, {
        TextStrokeTransparency = 1
    })
    tween:Play()
end)

Thank you!

1 answer

Log in to vote
0
Answered by 4 years ago

Make a Local Script in the StarterGui instead of using local script into the main Model

Example:

--StarterGui Script

Local ClickDetect = game.Workspace.Part.ClickDetector

ClickDetect.MouseClick:Connect(function()
--Do Something
end
0
This did not work :( Mr_Topsgaming -2 — 4y
0
topsgaming did you just copy the code from here or turned your script into a local script? 123nabilben123 499 — 4y
0
No I didn't copy the code, and I didn't just change a script into a local script. I took his idea and wrote code around that. I put a local script inside of the gui I want to animate and It still does not work. Mr_Topsgaming -2 — 4y
0
Only startergui not on screengui. HandznLegz 18 — 4y
Ad

Answer this question