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

How to make a remote event that passes player as argument? [closed]

Asked by
Cjjdawg -9
6 years ago

This question already has an answer here:

Remote Events - How to pass the player as a argument?

Server Script

local debounce = false 
local remoteEvent = Instance.new("RemoteEvent")
remoteEvent.Parent = game.ReplicatedStorage


local Detector = game.Workspace.city.SunGod.Detector.Touched:Connect(function(hit) -- Detector for the smoothie guide

    if hit.Parent:FindFirstChild("Humanoid") then 

        local sec = 1 -- Debounce time

        if debounce == false then

                debounce = true
                print("hi")

                --Talk Button Gui

                local player = game.Players:GetPlayerFromCharacter(hit.Parent)
                print(player.Name)
                local ScreenGui=Instance.new('ScreenGui',player.PlayerGui)
                local TalkButton=Instance.new('ImageButton',ScreenGui)
                TalkButton.Visible = true
                TalkButton.BackgroundTransparency=1
                TalkButton.BorderSizePixel=0
                TalkButton.Position = UDim2.new(0.582,0,0.481,0)
                TalkButton.Size = UDim2.new(0,100,0,100)
                TalkButton.Image = "rbxassetid://2172939584"


                --Detector if user presses the button

                TalkButton.MouseButton1Click:Connect(function()

                        print ("Hi")

                        sec = 30 --Debounce Delay

                        remoteEvent:FireServer(game.Players.) -- Activtating the Guide GUI


                end) --EndFunction
        wait(2)     
        TalkButton.Visible = false
                end --End Debounce



    wait(sec)
    debounce = false

    end -- End Humanoid Check

end)--End Function



Local Script

local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer


local function SmoothieGuide()


    print(player.Name)

    local Target = workspace.PortalSign
    local Current = workspace.CurrentCamera


    Current.CameraType = Enum.CameraType.Scriptable
    print (player.Name)         

    local DefaultSpeed = player:FindFirstChild("Humanoid").WalkSpeed
    player:MoveTo(Vector3.new(-1.04, 1.5, 144.097))
    player:FindFirstChild("Humanoid").WalkSpeed = 0




    local Gui=Instance.new('ScreenGui',player.PlayerGui)
    local frame = Instance.new('Frame',Gui)
    local Textbox = Instance.new('TextLabel',frame)
    local BG = Instance.new('ImageLabel',frame)



    BG.BorderColor3 = Color3.new(0,0,0)
    BG.BorderSizePixel = 4
    BG.ZIndex = 1
    BG.Image = "rbxassetid://2173160723"
    BG.Size = UDim2.new(0,558,0,100)
    BG.Position = UDim2.new(0.5,-279,0.5,-50)

    frame.BorderSizePixel= 0
    frame.BackgroundColor3 = Color3.new(255/255,255/255,255/255)
    frame.Visible=true
    frame.Position = UDim2.new(0.5,-279,0.5,-50)
    frame.Size = UDim2.new(0,558,0,100)
    frame.BackgroundTransparency = 0.3

    Textbox.Visible = true                  
    Textbox.BackgroundTransparency = 1
    Textbox.BorderSizePixel=0
    Textbox.Position = UDim2.new(0.5,-279,0.5,-50)
    Textbox.Size= UDim2.new(0,558,0,100)
    Textbox.Font = "Cartoon"
    Textbox.TextColor3= Color3.new(255/255,255/255,255/255)
    Textbox.TextSize = 30
    Textbox.TextWrapped = true
    Textbox.ZIndex = 2


    wait()
    Current.CameraSubject = game.Workspace.city.SunGod.Center
    Textbox.Text = "Hi! Welcome to Groovy Smoothie. I am the Sun Smoothie guide, and I'm gonna show you how to play groovy smoothie."

    wait(5)

    Textbox.Text = "First you should collect your smoothie ingredients by using the one of the portals.........."
    Current.CameraSubject = Target

    Current.CoordinateFrame = CFrame.new(Target.Sign.Position)  
                  * CFrame.Angles(0, -1.57, 0) --Rotation
                  * CFrame.new(0, 6, 17 )
    wait(5)

    Textbox.Text = ".......Then, come back to town and enter the smoothie factory building to make the smoothies"

    Target = workspace.city.SmoothieFactory.Door.Door1
    Current.CameraSubject = Target
    Current.CoordinateFrame = CFrame.new(Target.Position)  
                 * CFrame.Angles(0, 0, 0) --Rotation
                 * CFrame.new(5, 10 ,25 )

    wait(5)

    Textbox.Text = "Easy Right? , Making smoothies will give you smoothie points"

    wait(5)

    Textbox.Text = "There is also a store where you can upgrade your smoothie stick and backpack to make more Groovy Smoothies!!!"

    Target = workspace.city.VehicleStore.Detector
    Current.CameraSubject = Target
    Current.CoordinateFrame = CFrame.new(Target.Position)  
                * CFrame.Angles(0, 1.57, 0) --Rotation
                * CFrame.new(5, 10 ,25 )

    wait(5)

    Textbox.Text = "Groovy bucks can be earned by playing minigames, and can be used to purchase pets and vehicles"
    Target = workspace.CityPos
    Current.CameraSubject = Target
    Current.CoordinateFrame = CFrame.new(Target.Position)  
                * CFrame.Angles(0, 0, 0) --Rotation
                * CFrame.new(0, 0 ,0 )


    wait(5)

    Textbox.Text = "Thats all for now,  go have some fun"

    wait(3)


    frame.Visible = false  
    player:FindFirstChild("Humanoid").WalkSpeed =  DefaultSpeed
    player.Parent:MoveTo(Vector3.new(-12.605, 1.5, 144.575))

    game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
    game.Workspace.CurrentCamera.CameraType = "Custom"


end

remoteEvent.OnClientEvent:Connect(SmoothieGuide)


Marked as Duplicate by Vulkarin and User#19524

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?