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

i wonder why my server to client remote event isn't working?

so my server to client remote event isn't working. it is supposed to highlight the door handle but instead it does nothing and it doesn't have any errors.

the server script is:

local openDoor = script.Parent.Parent.Parent.DoorOpen

local closeDoor = script.Parent.Parent.Parent.DoorClose

local move = script.Parent.Parent.Move
local selection = script.Parent.SelectionBox 

local open = script.Parent.Parent.Open.Value

 

local clickdetector = script.Parent.ClickDetector

 

local tweenservice = game:GetService("TweenService")

local tweeninfo = TweenInfo.new(

            0.5,
            Enum.EasingStyle.Quad,
            Enum.EasingDirection.InOut,
            0,
            false,
            0
)
local function tweenModel(model, CF)
    local CFrameValue = Instance.new("CFrameValue")
    CFrameValue.Value = model:GetPrimaryPartCFrame()
    CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
        model:SetPrimaryPartCFrame(CFrameValue.Value)
    end)
 
    local tween = tweenservice:Create(CFrameValue, tweeninfo, {Value = CF})
    tween:Play()
    tween.Completed:Connect(function()

        CFrameValue:Destroy()

    end)

end

clickdetector.MouseClick:Connect(function(plr)
 
    if not open then
 
        open = true
 
        tweenModel(script.Parent.Parent,openDoor:GetPrimaryPartCFrame())
    elseif open then
        open = false
        tweenModel(script.Parent.Parent,closeDoor:GetPrimaryPartCFrame())
    end
 
        
 
end)

clickdetector.MouseHoverEnter:Connect(function(plr)
	
	game:GetService("ReplicatedStorage").Hover:FireClient(plr,selection)
	
end)

the local script is:

script.Parent.OnClientEvent:Connect(function(plr,selection)
	selection.Visible = true
end)

1 answer

✓ Accepted answer

The problem is, you have the localscript in the RemoteEvent, that doesn't work.

All you have to do is move the local script to StarterPlayer->StarterPlayerScripts

And then change the code to this:

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Hover")
remoteEvent.OnClientEvent:Connect(function(selection)--Note that it doesn't give you the plr value, when you do the :FireClient() the first value is the player you want to fire it to, and then the rest of the values is passed to the client.
    selection.Visible = true
end)

2 comments

0

thx

0

No problem!

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