Here is my script inside the workspace:
local replicatedstorage = game:GetService("ReplicatedStorage")
remote = replicatedstorage:WaitForChild("RemoteEvent")
local players = game:GetService("Players")
local blokje = game.Workspace.Aangeraakt
blokje.Touched:connect(function(otherpart)
if otherpart.Parent.Humanoid then
local player = otherpart.Parent:GetPlayerFromCharacter
remote:FireClient(player)
end
end)
Here is my localscript inside the starterplayerscripts:
local players = game:GetService("Players")
local replicatedstorage = game:GetService("ReplicatedStorage")
local player = players.LocalPlayer
local remote = replicatedstorage:WaitForChild("RemoteEvent")
local playergui = player.PlayerGui
local sound = Instance.new("Sound", playergui)
sound.SoundId = "rbxassetid://1280470"
local function SoundPlay()
local aangerakt = game.Workspace.Aangeraakt
aangerakt.Touched:connect(function(otherpart)
if otherpart.Parent.Humanoid then
sound:Play()
end
end)
end
remote.OnClientEvent:connect(SoundPlay)
The error from Roblox Studio: Workspace.Aangeraakt.Music:11: function arguments expected near 'remote'

3 comments
and the sound can only be heared by the localplayer who activated it
If only the localplayer can hear it, why don't you just create the sound in the localscript? Nobody would be able to hear it.
You used the GetPlayerFromCharacter() function improperly