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

Ok I understand remoteevents a bit... But what is happening here?

Asked by 9 years ago

Ok So I'm trying to make this script fire the OpenDoor Event (there is no errors what so ever) so it can animate a door being opening or closing but it seems I can't get it to open at all.

Door

Events Script It's in ServerScriptService Under a folder called Scripts

workspace:WaitForChild('Events').OpenDoor.OnServerEvent:connect(function(Player, DoorOC)
    local CheckForTool = false
    for _,Items in pairs(Player.Character:GetChildren()) do
        if Items.ClassName == 'Tool' then
            if Items.Name == 'DoorOC' then
                CheckForTool = true
                if DoorOC then
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,10,0)
                else
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,0,0)
                end
            end
        end
    end
end)

Interact Script This is in StarterPack I might had This is suppose to Fire when clicked

        elseif Target.Parent.Name == 'Door' then
            repeat wait() until game.Players.LocalPlayer.Character
            local Magnitude = (game.Players.LocalPlayer.Character.Torso.Position - Target.Position).magnitude
            if Magnitude < 10 then  
                workspace.Events.OpenDoor:FireServer(Target.Parent) 
            end 
0
Is the event actually happening? If you add `print(Player, DoorOC)` to the beginning of the server event, do you get output? BlueTaslem 18071 — 9y
0
Yes I get Output When added around Line 2 but when I add it around Line 11 I don't get any output Anciteify 70 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Is your script in a tool? Scripts in the Starterpack or Backpack do not get copied to the player's character when they are used. Try

workspace:WaitForChild('Events').OpenDoor.OnServerEvent:connect(function(Player, DoorOC)
    local CheckForTool = false
    for _,Items in pairs(Player.Backpack:GetChildren()) do
        if Items:IsA("Script") or Items:IsA("LocalScript") then
            if Items.Name == "DoorOC" then
                CheckForTool = true
                if DoorOC then
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,10,0)
                else
                    DoorOC.CFrame = DoorOC.CFrame * CFrame.new(0,0,0)
                end
            end
        end
    end
end)

Notice the double quotes around strings. I do not believe you can use character quotes. Also, :IsA() is a nice piece of synactic sugar for doing what you did there with ClassName()

Best of luck(And skillz) --Cantos

0
Script is not in a tool it's in StarterPack The other Events look for tool which the other ones do work. Anciteify 70 — 9y
0
What is PlayeDoorOC? KilowattLaser 5 — 9y
Ad

Answer this question