Hello, I am making a game, and my script is not giving any output or doing anything at all.
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Values = Player:WaitForChild("Values")
local SoundEffect = Values:WaitForChild("SoundEffect")
local DomainAnimation = Values:WaitForChild("DomainAnimation")
local DomainOpen = false
UIS.InputBegan:Connect(function(input)
if input == Enum.KeyCode.F then
if DomainOpen == false then
DomainOpen = true
ReplicatedStorage.Events.MakeDomain:FireServer(DomainAnimation, SoundEffect, Values)
end
end
end)
ServerScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Events.MakeDomain.OnServerEvent:Connect(function(player, DomainAnimation, SoundEffect, Values)
print('1')
local Sound = Instance.new("Sound", workspace)
Sound.SoundId = ("rbxassetid://"..SoundEffect)
Sound:Play()
print('1')
end)
Data:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DefaultSoundID = 6590357524
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local dataStoreKey = "dataStoreKey"
local dataStore = DataStoreService:GetDataStore("PlayerDataStore", dataStoreKey)
function onPlayerAdded(player)
local valuesFolder = Instance.new("Folder")
valuesFolder.Name = "Values"
valuesFolder.Parent = player
local soundEffect = Instance.new("StringValue")
soundEffect.Name = "SoundEffect"
soundEffect.Parent = valuesFolder
local domainAnimation = Instance.new("StringValue")
domainAnimation.Name = "DomainAnimation"
domainAnimation.Parent = valuesFolder
local success, playerData = pcall(function()
return dataStore:GetAsync(tostring(player.UserId))
end)
if success and playerData then
soundEffect.Value = playerData.SoundEffect or (6590357524)
domainAnimation.Value = playerData.DomainAnimation or ""
end
end
function onPlayerRemoving(player)
local success, error = pcall(function()
local playerData = {
SoundEffect = player.Values.SoundEffect.Value,
DomainAnimation = player.Values.DomainAnimation.Value,
}
dataStore:SetAsync(tostring(player.UserId), playerData)
end)
if not success then
warn("Failed to save player data:", error)
end
end
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local dataStoreKey = "YourDataStoreKey"
local dataStore = DataStoreService:GetDataStore("PlayerDataStore", dataStoreKey)
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)