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

Client > ServerEvent Issues?

Asked by 4 years ago

Server

game.ReplicatedStorage.StatusChange.OnServerEvent:Connect(function(StatusText)
    game.Lighting.Status.Time.Text = StatusText
    local sound = Instance.new("Sound",game.Workspace)
    sound.Name = "StatusChangedSound"
    sound.SoundId = "rbxassetid://".."138093550"
    sound.Looped = true
    local pitcher = Instance.new("PitchShiftSoundEffect",sound)
    pitcher.Octave = 0.815
    sound:Play()
    wait(2)
    sound:Destroy()
end)

Local

script.Parent.MouseButton1Click:Connect(function()
    local StatusText = "Lunch"
    game.ReplicatedStorage.StatusChange:FireServer(StatusText)
end)

Keeps saying "String Expected, Got Object"

0
The OnServerEvent automatically has a Player object parameter as it's first argument without you having to pass it in. On Line 1 of the server script do ...:Connect(function(player, StatusText) climethestair 1663 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Put .Name at line 2 of the serverscript, so the script ends up looking like this:

game.ReplicatedStorage.StatusChange.OnServerEvent:Connect(function(StatusText)
    game.Lighting.Status.Time.Text = StatusText.Name
    local sound = Instance.new("Sound",game.Workspace)
     print(StatusText)
    sound.Name = "StatusChangedSound"
    sound.SoundId = "rbxassetid://".."138093550"
    sound.Looped = true
    local pitcher = Instance.new("PitchShiftSoundEffect",sound)
    pitcher.Octave = 0.815
    sound:Play()
    wait(2)
    sound:Destroy()
end)

Player is an object value, and the script was expecting the .Name string. Please be sure to accept the answer if you felt this helped.

Ad

Answer this question